the whole script can be run, but there is something I don"t understand
Zip_command = "rar a% s% s"% (target," ".join (source) is not understood in thescript. I hope someone who understands it can explain the principle.
-sharp!/usr/bin/python
-sharp Filename:backupup_ver5.py
import os
import time
source = ["D:\\python-source\\nihao.txt"]
target_dir = "D:\\python-backup\\"
today = target_dir + time.strftime("%Y%m%d")
now = time.strftime("%H%M%S")
comment = input("Enter a comment -->")
if len(comment) == 0:
target = today + os.sep + now + ".zip"
else:
target = today + os.sep + now + "_" +\
comment.replace(" ","_") + ".zip"
if not os.path.exists(today):
os.mkdir(today)
print("Successfully create directory",today)
zip_command = "rar a %s %s"%(target," ".join(source))
if os.system(zip_command) == 0:
print("Successful backup to",target)
else:
print("Backup FAILE")