AttributeError:' str'对象没有属性' getcwd'

时间:2014-03-14 17:23:10

标签: python

我是python的新手。我试图在我当前的脚本目录中解压缩文件,但我无法完成这项工作......

zip = zipfile.ZipFile(os.getcwd() + '/Sample_APE_File.zip')
zip.extractall(os.getcwd())

错误:AttributeError: 'str' object has no attribute 'getcwd'

1 个答案:

答案 0 :(得分:3)

您为os分配了一个字符串值,它不再绑定到模块:

os = 'some string'

将其重命名为其他内容。