Python新手,问题多多啊,用的是Python3.3

源码:
import zipfile
import os
import time

source_dir = os.listdir(os.getcwd())
target=time.strftime('%Y%m%d%H%M%S') + '.zip'
myZipFile = zipfile.ZipFile(target,'w')
for root,dirs,files in os.walk(source_dir):
for vfileName in files:
fileName = os.path.join(root,vfileName)
myZipFile.write( fileName, fileName, zipfile.ZIP_DEFLATED )
print ( myZipFile.printdir() ) #print all files in zhe zip file,
myZipFile.close()

提示错误:
Traceback (most recent call last):
File "C:\Users\月\Desktop\Test\yasuo.py", line 9, in <module>
for root,dirs,files in os.walk(source_dir):
File "C:\Python33\lib\os.py", line 404, in walk
names = listdir(top)
TypeError: illegal type for path parameter

慕斯709654
浏览 1387回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python