-4
該腳本將文件保存爲"/home/name/main/all my files and stuff"
。我想將它保存爲"main/all my files and stuff"
。python os.walk將所有內容保存在目錄中
def zipit():
file_paths = ['/home/name/main/']
buffer= StringIO.StringIO()
z= zipfile.ZipFile(buffer, "w")
for p in file_paths:
for dir, subdirs, files in os.walk(p):
for f in files:
z.write(os.path.join(dir, f))
z.close()
buffer.seek(0)
final = HttpResponse(buffer.read())
final['Content-Disposition'] = 'attachment; filename=dbs_custom_library.zip'
final['Content-Type'] = 'application/x-zip'
return final
你什麼輸出? –
它的工作原理,但它保存從「/ home」開始,我希望它保存在「/ main」開始 – user1457212
在這個腳本中你指定你想從' –