如何判断一个字符串里面是否都是数字?
如题。我实在想不出来什么能用的办法了…… 我查了下https://www.runoob.com/python3/python3-check-is-number.html
试试吧 str1.isdigit() 本帖最后由 Daniel_Zhang 于 2021-5-5 20:09 编辑
肖-肖 发表于 2021-5-5 20:01
我查了下
https://www.runoob.com/python3/python3-check-is-number.html
试试吧
isdigit() 可以看阿拉伯数字的
https://www.runoob.com/python3/python3-string-isdigit.html
isnumeric() 可以看包括但不限于阿拉伯数字,中文数字(一二三)等
https://www.runoob.com/python3/python3-string-isnumeric.html
有 buit-in 没必要去自创函数,或者导包
页:
[1]