易截截图软件、单文件、免安装、纯绿色、仅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))

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


相关问答:

IIS 7 python 2.6 cgi 文件上传问题

我每次上传的文件读到的数据都不正确。2M 的图片读得10多K 。。哪位大侠可以帮帮我啊。
#!D:\ProgrammerTools\python26\python.exe
#encoding=utf-8
import cgitb
import os
cgitb.enable()
import cgi,urllib ......

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 ......

C# RSA Python - .NET技术 / C#

C#里面用using System.Security.Cryptography; RSACryptoServiceProvider加密过的消息
用Python Crypto中RSA的方法 能直接 解吗?
RSA加密方式不是统一的吗?需要注意些什么?

有帮助。但是没解决问题。。。
......

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

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

from tkinter import *
root = Tk()
e = StringVar()
t = 'cashlu'
def yanzheng():
if e ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号