码迷,mamicode.com
首页 > 编程语言 > 详细

python str转int

时间:2014-10-21 21:46:53      阅读:258      评论:0      收藏:0      [点我收藏+]

标签:on   as   python   type   class   string   c   import   port   

method 1

In [18]: str1 = ‘123‘

In [19]: a = int(str1)

In [20]: a
Out[20]: 123

In [21]: type(a)
Out[21]: int

method 2

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

python str转int

标签:on   as   python   type   class   string   c   import   port   

原文地址:http://my.oschina.net/frostz/blog/335910

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!