Backup script, failed to run, os.system (zip_command) returned 1

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! )

Mar.19,2022

after I have many methods in Baidu! Finally! It succeeded (this is probably the greatest joy of my self-study)

zip_command = "zip-qr'%s'%s"% before change (target,''.join (source))

after modification, zip_command = "zip port-qr port% s port% s"% (target,' port '.join (source))-sharp) in order to facilitate the understanding and identification of people who need it, the word "mouth" is used to indicate the space

.

has been successfully run and backed up (based on the fact that you installed zip, in windos and typed zip on the cmd command line, the installation is successful. How to install Baidu? I have seen a lot of articles, and this process will help you understand why. )

reasons and reasons
(target,'. Join (source) the space in "join (source))" can only identify multiple folders
why it was cancelled''by adding the space zip. He only left the sentence Baidu.
if any great god knows, leave a message to explain, I also need to know why this modification is successful.

Menu