简体   繁体   中英

Running patch within a function

I need to make some changes to an xml using a 'patch.txt' file, generated with diff, within a function.

I am able to do this on the command line with:

patch export.xml patch.txt 

but when I use

subprocess.run(["patch" "export.xml patch.txt"]) 

within a function, this process is not called.

Any ideas on how to perform patching within python code?

Space is the separator for the shell input. So the code should be:

subprocess.run(["patch", "export.xml", "patch.txt"]) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM