Python Error: module 'string' ha

2020-09-03  本文已影响0人  王叽叽的小心情

运行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()用法中。

上一篇下一篇

猜你喜欢

热点阅读