第二题
def name_of_email(addr): re_s = re.match(r'(<([a-zA-Z0-9\s\_]*)>)?\s*(.+)\@(.+\..+)$',addr) if re_s.group(2) != '' and re_s.group(2) != None: return re_s.group(2) elif re_s.group(3) != '' and re_s.group(3) != None: return re_s.group(3) else: return None assert name_of_email('<Tom Paris> tom@voyager.org') == 'Tom Paris' assert name_of_email('tom@voyager.org') == 'tom' print('ok')
Sign in to make a reply
Json_Zhang
第二题