system: windos
IDLE: spyder
Code (backup script):
-sharp!/usr/bin/python
-sharpFilname:backup_ver1.py
import os
import time
source = [r"D:\hao\nihao",r"D:\hao"]
target_dir = r"D:\ma"
target = target_dir + time.strftime("%Y%m%d%H%M%S") + ".zip"
zip_command = "zip-qr"%s"%s"%(target,"".join(source))
if os.system(zip_command) == 0:
print("Successful backup to",target)
else:
print("Backup FAILFD")
the zip path has been added to the environment variable path, and you can run zip in cmd
when these conditions are met, Backup FAILFD is returned finally
in order to rule out that I will os.system (zip_command) = = 1, running the script will successfully return Successful backup to D:ma20181226210814.zip (actually not executed)
what is the problem and how can I solve it? It has been stuck for many days, ask for help! Thank you, God! )