Python isnumeric() 方法检测字符串是否只由数字组成。这种方法是只针对unicode对象。注:定义一个字符串为Unicode,只需要在字符串前添加 'u' 前缀即可
<span style="font-size:18px;">#coding:utf-8
str1 = u"yuanyuan123123"
print str1.isnumberic()
str2 = u"2582587758"
print str2.isnumberic()
</span>
Python isnumeric() 方法检测字符串是否只由数字组成。这种方法是只针对unicode对象。注:定义一个字符串为Unicode,只需要在字符串前添加 'u' 前缀即可
<span style="font-size:18px;">#coding:utf-8
str1 = u"yuanyuan123123"
print str1.isnumberic()
str2 = u"2582587758"
print str2.isnumberic()
</span>