使用gitbash在python中重定向

时间:2019-06-05 14:07:23

标签: python-2.7

$ python -i test.py
系统找不到指定的路径。(system could not find the path)
>>> Stopped

$ cat test.py
#!/usr/bin/python
import os
cmd = "ls -l >/dev/null 2>&1"
os.system(cmd)

当我在带有gitbash的Python中使用标准输出重定向时,它只是不起作用,而当直接在gitbash中运行命令时,它会很好地工作。

$ ls -l >/dev/null 2>&1

有没有人遇到过这个问题或可能会有所帮助?

1 个答案:

答案 0 :(得分:0)

我在链接下面找到了根本原因,希望它可能对您有所帮助 https://superuser.com/questions/777198/equivalent-of-foo-dev-null-in-windows-shell

相关问题