import re
text ='''Suppose my Phone No. is 0535-1234567,yours is 010-12345678,his is 025-87654321.'''#注意,下面的正则表达式中大括号内逗号后面不能有空格
matchResult = re.findall(r'(\d{3,4})-(\d{7,8})', text)for item in matchResult:print(item[
正则表达式 案例使用正则表达式提取字符串中的电话号码。import retext = '''Suppose my Phone No. is 0535-1234567,yours is 010-12345678,his is 025-87654321.''' #注意,下面的正则表达式中大括号内逗号后面不能有空格matchResult = re.findall(r'(\d{3,4})-(\d{7,8})', text)for item in matchResult: print(item