+ -
当前位置:首页 → 问答吧 → 关于python简明教程中的一个例子

关于python简明教程中的一个例子

时间:2011-01-09

来源:互联网

http://woodpecker.or​g.cn/abyteofpython_c​n/chinese/ch10s02.ht​ml#first 

这里的第一种解决方法. 请问在Windows下如何实现. 我用的是7Z 并加入了环境变量。 请问如何调用。 
target = target_dir + time.strftime('%Y%m%d%H%M%S') + '.zip' 这行是什么意思呢? 
zip_command = "zip -qr '%s' %s" % (target, ' '.join(source)) 这行呢? 
新手。请勿见笑。

作者: mythxox   发布时间: 2011-01-09

加print语句把target和zip_command打印出来应该就能明白吧...

作者: angel_su   发布时间: 2011-01-09

引用楼主 mythxox 的回复:
这里的第一种解决方法. 请问在Windows下如何实现. 我用的是7Z 并加入了环境变量。 请问如何调用。
target = target_dir + time.strftime('%Y%m%d%H%M%S') + '.zip' 这行是什么意思……

压缩目标,就是由路径+文件名+后缀,文件名就是时间格式的字符串,后缀是zip

zip_command = "zip -qr '%s' %s" % (target, ' '.join(source)) 这行呢?  

生成一个字符串,内容是zip -qr 压缩目标 压缩源文件

lz应该查一下7z的命令格式然后重写这句话。

作者: luotuo512   发布时间: 2011-01-09

target = target_dir + time.strftime('%Y%m%d%H%M%S') + '.zip'
字符串拼接
zip_command = "zip -qr '%s' %s" % (target, ' '.join(source))
格式化字符串

作者: xmnathan   发布时间: 2011-01-09

引用 2 楼 luotuo512 的回复:
引用楼主 mythxox 的回复:
这里的第一种解决方法. 请问在Windows下如何实现. 我用的是7Z 并加入了环境变量。 请问如何调用。
target = target_dir + time.strftime('%Y%m%d%H%M%S') + '.zip' 这行是什么意思……

压缩目标,就是由路径+文件名+后缀,文件名就是时间格式的字符串,后缀是zip

zip_comman……


我用的是7-ZIP 压缩命令为 7z a XX.7z 目标文件  
那我应该怎么写zip_command呢?

作者: mythxox   发布时间: 2011-01-09