|
发表于 2018-4-26 07:25:02
|
显示全部楼层
正确的。可能是你的版本的问题。我使用2.7.14及3.6.5均正常运行。运行情况如下:
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> a = 520
>>> str(a)
'520'
>>> a = '520'
>>> int(a)
520
>>> float(a)
520.0
>>>
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> a = 520
>>> str(a)
'520'
>>> a = '520'
>>> int(a)
520
>>> float(a)
520.0
>>> |
|