说明
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学习指路:
本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。
Copyright © 2019- yule263.com 版权所有 湘ICP备2023023988号-1
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务