![](/img/trans.png)
[英]Patch a function call within function from different file using Python
[英]Running patch within a function
我需要在一個函數中使用 diff 生成的“patch.txt”文件對 xml 進行一些更改。
我可以在命令行上執行此操作:
patch export.xml patch.txt
但是當我使用
subprocess.run(["patch" "export.xml patch.txt"])
在一個函數中,這個過程不會被調用。
關於如何在 python 代碼中執行修補的任何想法?
空格是 shell 輸入的分隔符。 所以代碼應該是:
subprocess.run(["patch", "export.xml", "patch.txt"])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.