import re
str = '546456sfdsa'
pattern = re.compile('[0-9]+')
match = pattern.findall(str)
if match:
print ('contains digital')
else:
print ('not contains digital')
正则表达式学习链接:
https://www.cnblogs.com/chuxiuhong/p/5885073.html
http://www.cnblogs.com/chuxiuhong/p/5907484.html
http://www.runoob.com/python/python-reg-expressions.html
网友评论