首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

python在解析加密压缩包时候的类型异常,求高手赐教

2012-09-07 
python在解析加密压缩包时候的类型错误,求高手赐教Python codepassword 3dvvva432535gfdfgdf70202060c

python在解析加密压缩包时候的类型错误,求高手赐教

Python code
password = "3dvvva432535gfdfgdf70202060c"#解压缩加密zip文件def Unzip(target_dir,filename):    target_name= target_dir+ '\\' +filename    zipfiles= zipfile.ZipFile(target_name,'r')    save_path = target_dir+ '\\' + "here" #保存文件的路径    zipfiles.extractall(path = save_path,members=zipfiles.namelist(),pwd =password)    zipfiles.close()    print("Unzip finished!")


解析的时候,报类型错误:

错误详细信息:<class 'TypeError'> pwd: expected bytes, got <class 'str'>

请教是为什么啊?



[解决办法]
代码没问题啊
就看你传的target_dir和文件名对不对了
[解决办法]
zipfiles.extractall(path = save_path,members=zipfiles.namelist(),pwd =password.encode('utf-8'))

热点排行