【问题标题】:Why does using tarfile.extract() result in error: no attribute 'extract'?为什么使用 tarfile.extract() 会导致错误:没有属性“提取”?
【发布时间】:2016-07-07 23:57:23
【问题描述】:

我正在使用 Python 3.4。 写作

csv_f = tarfile.open('C:\\Users\\somefile.gz')

工作正常,但是这个

csv_f = tarfile.extract('C:\\Users\\somefile.gz') 

引起反应

AttributeError: 'module' object has no attribute 'extract'

似乎在库中找不到 extract 和 extractall 函数。怎么可能?

【问题讨论】:

    标签: python tarfile


    【解决方案1】:

    因为它们是 tarfile.open() 返回的对象的方法,而不是模块本身的函数。

    【讨论】:

    • 谢谢!如何在 tar 文件中使用正确的语法来提取文件?
    • 就像文档说的那样,你将它传递给要提取的成员。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-04
    • 2020-07-16
    • 2014-06-05
    相关资源
    最近更新 更多