isdecimal(...)|      S.isdecimal() -> bool|      |      Return True if there are only decimal characters in S,|      False otherwise.
翻译:如果S中只有十进制字符,则返回True,否则为False。
isdigit(...)|      S.isdigit() -> bool|      |      Return True if all characters in S are digits|      and there is at least one character in S, False otherwise.
翻译:如果S中的所有字符都是数字,并且在S中至少有一个字符,则返回True。
isnumeric(...)|      S.isnumeric() -> bool|      |      Return True if there are only numeric characters in S,|      False otherwise.翻译:如果S中只有数字字符,则返回True,否则为False。
1 s = '123'
2 print(s.isdigit())
3 print(s.isdecimal())
4 print(s.isnumeric())

结果为:

True
True
True
s = b'123'
print(s.isdigit())
#print(s.isdecimal())
#print(s.isnumeric())

结果为: (只有第一个能正常输出,另外两个报属性错误)

True
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-19-9e3f7cdf9524> in <module>()2 print(s.isdigit())3 #print(s.isdecimal())
----> 4 print(s.isnumeric())AttributeError: 'bytes' object has no attribute 'isnumeric'
s = '123.0'
print(s.isdigit())
print(s.isdecimal())
print(s.isnumeric())
False
False
False
s = '三叁'
print(s.isdigit())
print(s.isdecimal())
print(s.isnumeric())
False
False
True
s = 'Ⅲ'
print(s.isdigit())
print(s.isdecimal())
print(s.isnumeric())
False
False
True总结:
isdigit()
True: Unicode数字,byte数字(单字节),全角数字(双字节)
False: 汉字数字,罗马数字,小数
Error: 无 isdecimal()
True: Unicode数字,全角数字(双字节)
False: 罗马数字,汉字数字,小数
Error: byte数字(单字节) 
isnumeric()
True: Unicode数字,全角数字(双字节),罗马数字,汉字数字
False: 小数
Error: byte数字(单字节)

python中isdigit()、isdecimal()和isnumeric的区别!相关推荐

  1. python中str函数isdigit、isdecimal、isnumeric的区别

    python中str函数isdigit.isdecimal.isnumeric的区别 num = "1"  #unicode num.isdigit()   # True num. ...

  2. isdigit php,python中str内置函数isdigit、isdecimal、isnumeric的区别

    isdigit.isdecimal.isnumeric的区别 isdecimal(...) | S.isdecimal() -> bool | | Return True if there ar ...

  3. python判断字符串,str函数isdigit、isdecimal、isnumeric的区别

    s为字符串 s.isalnum() 所有字符都是数字或者字母 s.isalpha() 所有字符都是字母 s.isdigit() 所有字符都是数字 s.islower() 所有字符都是小写 s.isup ...

  4. Python中爬虫框架或模块的区别

    Python中爬虫框架或模块的区别,我们在Python的学习过程中,需要不断的总结知识点,这样我们才能进步的更快一些. (1)爬虫框架或模块 Python自带爬虫模块:urllib.urllib2; ...

  5. Python中值传递和引用传递区别

    原文:http://blog.csdn.net/xuqiaobo/article/details/72236539 举例,函数参数如果是dic,都不需要返回值,原值就被改变了 def aa(dic): ...

  6. Python中str()与repr()函数的区别——repr() 的输出追求明确性,除了对象内容,还需要展示出对象的数据类型信息,适合开发和调试阶段使用...

    Python中str()与repr()函数的区别 from:https://www.jianshu.com/p/2a41315ca47e 在 Python 中要将某一类型的变量或者常量转换为字符串对象 ...

  7. python中列表 元组 字典 集合的区别

    参考文章:python中列表 元组 字典 集合的区别

  8. Python中爬虫框架或模块的区别!

    Python中爬虫框架或模块的区别,我们在Python的学习过程中,需要不断的总结知识点,这样我们才能进步的更快一些. (1)爬虫框架或模块 Python自带爬虫模块:urllib.urllib2; ...

  9. 【Python】Python中str()和repr()函数的区别

    作用 在 Python 中要将某一类型的变量或者常量转换为字符串对象通常有两种方法,即 str() 或者 repr() . 区别与使用 参考文章:Python 中 str() 和 repr() 函数的 ...

  10. python中的return和print的区别_python中return和print的区别(详细)

    Huskiesir python最近正在研究.今天,我面临一个问题,那就是,返回和印刷的区别.双方都能输出结果.的区别是什么?闲话少说,看下面的例子.# Code1: def break_words( ...

最新文章

  1. 2 模版_轻量html模版渲染库 cJinja
  2. cs224n第一讲深度自然语言处理
  3. chromedriver与chrome版本映射表
  4. 【HDU 3400】Line belt(三分法)
  5. 【C语言笔记初级篇】第六章:指针入门
  6. net core 中间件(MiddleWare)
  7. C#LeetCode刷题之#11-盛最多水的容器(Container With Most Water)
  8. 关于git的cherry-pick命令
  9. sun服务器如何查cpu信息,solaris 如何查看CPU信息
  10. java+mysq 基于jsp825幼儿园管理系统(java,web)
  11. python xlwt修改excel_通过Python模块xlwt更改xls文件中的默认分页符
  12. 那些年,我们一起做过的 Java 课后练习题(71 - 75)
  13. solver参数详解
  14. python安装requirement.txt
  15. python实现动态地图_使用Python、Geopandas和Matplotlib制作gif动态地图
  16. 北京办理居住证的全流程
  17. 与人斗其乐无穷,教你回答职场送命题!
  18. html显示latex公式,wordpress显示数学公式插件【LaTeX转HTML】
  19. 3-D Quasi-Recurrent Neural Network for Hyperspectral Image Denoising
  20. 360免费WiFi连接不上了

热门文章

  1. python抖音github_GitHub - eternal-flame-AD/Douyin-Bot: Python 抖音机器人,论如何在抖音上找到漂亮小姐姐?...
  2. lda 可以处理中文_用python处理文本数据
  3. Effective Java之当心字符串连接的性能(五十一)
  4. 剑指 Offer 31. 栈的压入、弹出序列【无取巧,易于理解!】
  5. 【已解决】Class not found: “com.bjpowernode.MyTest“
  6. 【解析】1013 Battle Over Cities (25 分)_31行代码AC
  7. ArrayBlockingQueue中的方法
  8. 电脑计算机的硬盘那些可以删除吗,我的电脑出现多个可移动磁盘该怎么删除?...
  9. shell之case和循环语句(case语句的格式与举例)(for循环,while循环until循环语句的详解和continue,break解释, 九九乘法口诀表 ,等腰三角形)
  10. Linux KVM 虚拟化技术