Discuss / Python / 打卡

打卡

Topic source

°Destiny

#1 Created at ... [Delete] [Delete and Lock User]

第一题

def is_valid_email(addr):
    if re.match(r'([a-zA-Z]+|[a-zA-Z]+\.[a-zA-Z]+)@[a-zA-Z]+.com',addr):
        return True
    else :
        return False

第二题

def name_of_email(addr):
    m=re.match(r'<?([a-zA-Z\s]+)>?\s?([a-zA-Z]+)?@([a-zA-Z]+).([a-zA-Z]+)',addr)
    print(m.group(2))  #第一个打印输出tom 第二个打印输出None
    return m.group(1)

  • 1

Reply