运行Python代码遇到该问题:AttributeError: module 'string' has no attribute 'atof'
InterData[n1][n2] = string.atof(rcd[2])
AttributeError: module 'string' has no attribute 'atof'
原因:string.atof()
是Python2.0版本中的用法
解决:在Python3.0版本中直接采用int()
即可解决。
类似的用法还有Python2.0中为提高性能的xrange()
在Python3.0版本中直接内嵌在range()
用法中。
网友评论