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

Getting an `stdin is not a tty` error when using python json.tool in git bash

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

$ echo '{"print": "this"}' | python -m json.tool
stdin is not a tty

我的 Python 版本是 2.7.15 (Anaconda)。

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

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

这似乎是 winpty issue, as