python: isdigit int float 使用

>>> num1 = '2.0'
>>> print num1.isdigit()
False
>>> num2 = '2'
>>> print num2.isdigit()
True
>>> num3 = '-3'
>>> print num3.isdigit()
False
>>> num4 = '3.0'
>>> print int(num4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '3.0'
>>> num5 = '3'
>>> print int(num5)
3
>>> num6 = '3'
>>> print float(num6)
3.0
>>> num6 = '-3'
>>> print int(num6)
-3
>>> 

posted on 2016-10-14 14:12  ZhYQ_note  阅读(560)  评论(0编辑  收藏  举报

导航