Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> s1 = '123'
>>> s1
'123'
>>> i1 = int(s1)
>>> i1
123
>>> type(i1)
<class 'int'>
>>> s2 = '123.4'
>>> f2 = float(s2)
>>> f2
123.4
>>> type(f2)
<class 'float'>
温馨提示:答案为网友推荐,仅供参考