python ide vs cmd线检测?

0 python

在我使用的两个IDE中编程时,当我使用raw_input时会发生不好的事情.但是在命令行上它完全符合我的预期.通常这个应用程序是在cmd行中运行,但我喜欢在IDE中编辑和调试它.有没有办法检测我是否在IDE中执行了应用程序?

jfs*_*jfs 5

if sys.stdin.isatty():
   # command line (not a pipe, no stdin redirection)
else:
   # something else, could be IDE
Run Code Online (Sandbox Code Playgroud)