![图片[1]-python如何判断是否数字类型-uusu优素-乐高,模型,3d打印,编程](http://uusucn.zbbe.cn/wp-content/uploads/2024/01/5e730d8539d05413.jpg)
python中有一个自带的函数isdigit,可以返回某字符串是不是数字。如果是数字,返回True;反之,返回False。
str1='1' print(str1.isdigit()) str2='1.1' print(str2.isdigit()) str3='-1' print(str3.isdigit()) str4='a' print(str4.isdigit())
它的运行结果是:
True False False False原文来自:https://www.py.cn
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END


















































暂无评论内容