注册 登录
编程论坛 Python论坛

初学python,关于zip 命令

fs2012 发布于 2012-11-09 10:33, 698 次点击
初学python,可能问的问题有点奇怪。
我照网上的例子抄了一份backup.py

1 import os
2 import time

3 source=[r'C:\My Documents', r'F:\account']
4 target_dir = r'F:\book'
5 target =target_dir + time.strftime('%Y%m%d%H%M%S') + '.zip'

6 zip_command = ''zip -qr {} {}'' .format(target, ''.join(source))

7 print(zip_command)
然后运行的时候出现
6 zip_command = ''zip -qr {} {}'' .format(target, ''.join(source))
这一行错误:syntaxerror:invalid syntax

请问如何解决这个问题,已经安装了gnuwin32.


[ 本帖最后由 fs2012 于 2012-11-9 15:21 编辑 ]
2 回复
#2
木头lbj2012-11-15 19:25
在windows下的操作不是很清楚。我只是来提个建议。python的代码严格缩进,希望以后用代码贴出来。
#3
亲爱的自己2013-01-15 22:10
学习了!
1