# 第28章示例:邮箱格式校验

import re

def check_email(email):
    """检查邮箱格式:用户名@域名.后缀"""
    pattern = r"[\w.]+@[\w.]+\.\w+"
    if re.match(pattern, email):
        print(f"✅ {email} 格式正确")
    else:
        print(f"❌ {email} 格式不对")

check_email("peter.ma@qq.com")      # ✅
check_email("hello@163.com")        # ✅
check_email("hello@")               # ❌
check_email("nobody@@qq.com")       # ❌
check_email("no space@qq.com")      # ❌
