简体   繁体   中英

Detect how I run Python script

如何在不向脚本传递不同参数的情况下检测脚本是从Windows控制台还是从Komodo调试器运行?

Although I don't know Komodo, I don't think its standard input is interactive, so you could try

import sys
in_console = sys.__stdin__.isatty()

in_console will then be true if the invoker provides interactive stdin and you will get what you want, though not in an elegant way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM