今天爱分享给大家带来python如何判断一个字符串是数字【面试题详解】,希望能够帮助到大家。
使用这种方法会不会十分丑陋和低效
def is_number(s):
try:
float(s)
return True
except ValueError:
return False
使用这种方法并不丑陋和低效
使用isdigit(缺点,对非整数无能为力)
a = "03523" a.isdigit()
原文链接:http://blog.itblood.com/3906.html,转载请注明出处。

![[3D/汉化]梅麻吕合集18部 [游戏+动画+安卓]合集[48G]](/wp-content/uploads/replace/2025/11/02/311578e7aa20343ce9d3920950d60f16.webp)