2024-04-25 04:40:08 发布
网友
我是python新手,尝试在python脚本中使用git命令。 要求是我需要在python脚本中调用一些git命令,比如git clean和git reset命令。我需要使用subprocess,因为我不能使用任何像GitPython这样的外部库。你知道吗
任何帮助都将不胜感激
谢谢。你知道吗
你可以像下面那样使用它
import shlex import subprocess command= "git clean -df" # you can paste any command here comm=shlex.split(command) # This will convert the command into list format proc=Popen(comm) # This will execute your command
有关详细信息,请参阅此处
https://docs.python.org/2/library/subprocess.html
你可以像下面那样使用它
有关详细信息,请参阅此处
https://docs.python.org/2/library/subprocess.html
相关问题 更多 >
编程相关推荐