美文网首页
Python Error: module 'string' ha

Python Error: module 'string' ha

作者: 王叽叽的小心情 | 来源:发表于2020-09-03 10:52 被阅读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()用法中。

    相关文章

      网友评论

          本文标题:Python Error: module 'string' ha

          本文链接:https://www.haomeiwen.com/subject/izensktx.html