为什么Python在命令提示符不出错时给出错误?

时间:2015-11-22 20:31:49

标签: python git batch-file cmd

我最近因GitHub错误丢失了所有数据。我找到了一种逐一检索信息的方法。见这里:Why did the GitHub windows client delete all of my work?。我现在决定制作一个Python程序来自动检索数据。我手动完成了这个过程,它工作正常。出于某种原因,当我调用命令$header_size=curl_getinfo($ch,CURLINFO_HEADER_SIZE); $header=trim(substr($content,0,$header_size)); //Get the header and trim it to remove \r\n $body=substr($content,$header_size); //Get the body 时,它返回:git cat-file -t code。您用十六进制数替换代码。例如,fatal: Not a valid object name code。我在for循环中这样做。我用

0921d007bc8ca0000a587181263cf4f8d4d38e31

运行命令提示符命令。有人可以解释为什么这个错误只发生在Python中,如果我做错了什么或者我应该修复一些东西。

谢谢!

1 个答案:

答案 0 :(得分:0)

出于某种原因,我使用了shell=False。如果将其更改为shell=True,则可以正常工作。启用它时,它会模拟shell并正常工作。