读书人

python 3.2中用string.atoi()产生异常

发布时间: 2012-03-08 13:30:13 作者: rapoo

python 3.2中用string.atoi()产生错误,如何解决?
> > > import string
> > > string.atoi( '10 ') + 4
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
string.atoi('10') + 4
AttributeError: 'module' object has no attribute 'atoi'


我按照 [征服PYTHON:语言基础与典型应用].孙广磊.完美书签.清晰PDF版
里原样写的代码,为什么是错误的。原书用的是Python 2.5


[解决办法]
好垃圾的书。

Python code
int('10') + 4
[解决办法]
这啥书啊
atoi一看就是c/c++转过来的
python讲的是简洁,直接int(str)和str(int)互相转来转去多方便
[解决办法]
python3没有向下兼容,你要使用python3的话需要看python3的书

读书人网 >perl python

热点推荐