我正试图从短信中提取电话号码。但我不希望手机被重新格式化,提取号码部分或其他任何东西,但我只希望从文本中提取未更改的原始电话号码字符串,而不是重新格式化的原始字符串。 我用PhoneNumberMatcher()方法尝试了“phonenumbers”库(https://github.com/daviddrysdale/python-phonenumbers)。它工作得很好,在获取格式化电话号码的意义上,这是我不需要的,我只需要电话号码的原始子字符串。有办法吗
for match in phonenumbers.PhoneNumberMatcher(text, "US"):
unformatted_phone = match.number
#formatted_phone = str(match.number)
#formatted_phone = phonenumbers.format_number(match.number, None)
formatted_phone = phonenumbers.format_number(match.number, phonenumbers.PhoneNumberFormat.INTERNATIONAL)
好的,我知道了,是的。粗线
相关问题 更多 >
编程相关推荐