【问题标题】:Returns the total number of words in the text of a file [closed]返回文件文本中的总字数 [关闭]
【发布时间】:2018-11-14 04:26:59
【问题描述】:

我正在使用 Python 3,我正在尝试编写一个函数,该函数将文件名作为参数并返回该文件文本中的总字数。我不断收到错误“AttributeError:'_io.TextIOWrapper' 对象没有属性'closes'”,我不知道如何解决它。任何帮助将不胜感激。

【问题讨论】:

标签: python python-3.x filenames


【解决方案1】:

问题是您引用了无效的函数。 file.closes() 应该是 file.close()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-18
    • 2019-12-22
    • 1970-01-01
    • 2023-03-13
    • 1970-01-01
    相关资源
    最近更新 更多