前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【说站】python中isnumeric如何使用

【说站】python中isnumeric如何使用

作者头像
很酷的站长
发布2022-11-23 16:30:58
4560
发布2022-11-23 16:30:58
举报
文章被收录于专栏:站长的编程笔记

python中isnumeric如何使用

说明

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

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

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

实例

代码语言:javascript
复制
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学习指路:python基础教程

本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • python中isnumeric如何使用
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档