在 git bash 中使用 python json.tool 时出现“stdin is not a tty”错误

G. *_*lon 4 windows tty python-2.7 git-bash

我在 Windows 上使用 Git Bash,尝试使用命令行漂亮地打印 JSON 输出。根据这个答案,我尝试以下操作:

$ echo '{"print": "this"}' | python -m json.tool
stdin is not a tty
Run Code Online (Sandbox Code Playgroud)

我的Python版本是2.7.15(Anaconda)。

当我使用本机 Windows cmd 尝试相同的操作时,它可以正常工作(但我想使用 Bash)。

Von*_*onC 11

echo '{"print": "this"}' | python.exe -m json.tool在 git bash 会话中效果更好(添加到.exepython)。

这似乎是一个winpty 问题,如此处所示