3

The official manual in python 3.6 suggestes using subprocess instead of os.system,

but I find sometime the subprocess do not work,

like if I want to run a git command.

os.system("git add .") # This works
gadd = subprocess.run(["git add ."]) # this shows a FileNotFoundError
gadd = subprocess.run(["git", "add ."]) # this shows [git: 'add .' is not a git command.]

Well, how can I run this git command correctly in subprocess? I tried call(), it is just the same as run().

I searched in google and stackoverflow, but almost all posts just say how to run 'ls -l'. Well ,that is easy, but this seems not.

jetorz
  • 157
  • 3
  • 9

0 Answers0