value = 'ad.41.bd'
if len(value) == len(value.strip({0,1,2,3,4,5,6,7,8,9})):
# no numbers
else:
# numbers present
在 Python 中有更简洁的方法来检测字符串中的数字吗?
最佳答案
这个呢?
import re
if not re.search('\d+', value):
# no numbers
else:
# numbers present
关于python - 检测字符串中的数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6649096/