pythonisnumeric如何使用

python中isnumeric如何使用

说明

1、判断字符串是否只由数字(支持罗马数字、汉字数字等)组成。

2、如果字符串只由数字组成,则返回True,否则返回False。

不仅支持Unicode数字、还支持全角数字(双字节)、罗马数字以及汉字数字

实例

str1=u'mr12468'

print(str1.isnumeric())#False

str1=u'12468'

print(str1.isnumeric())#True

str1=u'ⅠⅡⅣⅦⅨ'

print(str1.isnumeric())#True

str1=u'㈠㈡㈣㈥㈧'

print(str1.isnumeric())#True

str1=u'①②④⑥⑧'

print(str1.isnumeric())#True

str1=u'⑴⑵⑷⑹⑻'

print(str1.isnumeric())#True

str1=u'⒈⒉⒋⒍⒏'

print(str1.isnumeric())#True

str1=u'壹贰肆陆捌uuu'

print(str1.isnumeric())#False

以上就是python中isnumeric的使用,希望对大家有所帮助。更多Python学习教程请关注我们

推荐阅读