挣扎了两个星期。我无法解压这个 .zip。我知道这是正确的,因为我可以让它在标准命令行中工作,并且它显示了我所知道的所有内容。尝试解压缩 zip,然后重命名该文件的一部分并将其复制到另一个文件夹。这是基本设置:
import subprocess
cmd = ['7z', 'e', 'site']
sp = subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
导入后,我尝试使用以下方法解压它:
sp.communicate([cmd, 'r"C:\Users\boster\desktop\data1.zip"'])
现在它已经过了这一点,因为它移动到我的 if else 部分,但它没有解压它。我知道它将运行以下内容,因为它到达末尾并返回我的 else 语句,然后提示我再次运行数据。
if "sz + business_date" == name:
shutil.copy(sz%s) % business_date
os.renames(sales.xls)
shutil.copy(sc%s) % business_date
os.renames(cosales.xls)
shutil.copy(aj%s) % business_date
os.renames(money.xls)
shutil.copy(cc%s) % business_date
os.renames(count.xls)
else:
print "Repoll %s for %s" % (item, business_date)
print "Once information is downloaded press enter."
re_download = raw_input(" ")
data_one()
我省略了一些像 business_date 部分这样的东西,因为它在 else 中将其作为变量返回,所以我知道它正确地获取了这些信息。我只是不知道为什么这不会解压缩。请帮忙。如果这还不够,我会上传整个模块,如果你愿意的话。