易截截图软件、单文件、免安装、纯绿色、仅160KB

python 文件备份错误

#! c:\python26
# Filename: backup_ver1.py
import os
import time
source=[r'C:\test', r'C:\test1']
target_dir='D:\\back\\'
target=target_dir+time.strftime('%Y%m%d%H%M%S')+'.zip'
zip_command="rar a -r \"%s\" \"%s\"" %(target,''.join(source))
if os.system(zip_command)==0:
  print'successful backup to',target
else:
  print'backup failed'

在dos下运行,提示“不能读取c:\testc:\test1的内容” ,如果改为“source=r'C:\test'” ,只备份一个目录,可以运行。
不知道怎么解决
''.join(source)

==>

' '.join(source)

记着两个单引号中间是个空格。

如果是空格,在dos运行提示“找不到指定路径”,不能空格的

逻辑有点问题,这个应该能工作:

zip_command="rar a -r \"%s\" \"%s\"" % (target, "\" \"".join(source))

呵呵,和我一样也在学这节呢
{{


相关问答:

python怎么print 'hello world'

大家好,我是一个新手,刚开始学python,但是刚开始的helloworld都没法打印,让我很无奈。
我的python安装路径为f:\python31。在path中也设置对了,在windows下运行是这样显示的,希望各位前辈指点一下。谢谢
Pyth ......

python 正则匹配中文

在文本文件中匹配项包含中文
如内容为:gamename=中文 
  key=天下
文本文件的编码的文件为utf-8
python代码如下:
# -*- coding:UTF-8 -*-
  contents=open(from_pa ......

python中字符串比较的问题的问题

以下代码是Tk做了一个简单的密码验证功能,输入一个字符串,并验证其是否正确,请先看代码:
Python code:

from tkinter import *
root = Tk()
e = StringVar()
t = 'cashlu'
def yanzheng():
if e ......

python win下调用dll

  小弟接触python 2个星期了,安装的是python3.1版。
我用的是windows7,想写个调用dll的程序实践。问题来了:

C++代码:
extern "C" int __stdcall test();

int __stdcall te ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号