import re
def validate_email(email):
    pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
    if re.match(pattern, email):
        return True
    else:
        return False
# 测试
email1 = 'user.name@example.com'
email2 = 'user@domain'
email3 = 'invalid_email'
print(validate_email(email1))  # 输出: True
print(validate_email(email2))  # 输出: False
print(validate_email(email3))  # 输出: False
