In [18]: str1 = ‘123‘ In [19]: a = int(str1) In [20]: a Out[20]: 123 In [21]: type(a) Out[21]: int
In [22]: str1 = ‘123‘ In [23]: import string In [24]: a = string.atoi(str1) In [25]: a Out[25]: 123 In [26]: type(a) Out[26]: int
原文:http://my.oschina.net/frostz/blog/335910