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))
呵呵,和我一样也在学这节呢
{{
相关问答:
像 C 的 scanf() 那样
比如读入 1 2 3 a b c
每次读入一个
下面这个应该是你想要的吧:
Python code:
>>> k = raw_input()
0 0123 ds dsl sd
>>> k
'0 0123 ds dsl sd'
>>> ......
C#里面用using System.Security.Cryptography; RSACryptoServiceProvider加密过的消息
用Python Crypto中RSA的方法 能直接 解吗?
RSA加密方式不是统一的吗?需要注意些什么?
有帮助。但是没解决问题。。。
......
RT。
我想要下载一个网站上的图片,但是该网站的图片地址是通过浏览器执行网页的JavaScript脚本后才返回的,使用urllib2的urlopen只能得到带有JavaScript代码的网页源代码。
想要用wx模块的wx.lib.iew ......
RowNum=18
ColumnNum=10
SquareList=[[0 for a in range(ColumnNum)] for b in range(RowNum)]
ActiveList=[[0 for a in range(ColumnNum)] for b in range(RowNum)]
ActiveList[0][5]=1
SquareL ......
Python code:
class Rectangle:
def __init__(self, width, height):
self.width = width
self.height = height
def paint(self, factory):
point = factory.getPoint()
......