0
可能重复:
tell whether python is in -i mode
Tell if python is in interactive modepython脚本可以通过交互选项'-i'知道它是否可以运行?
有没有一种方法来检查python脚本是否已运行与互动-i选项?
例如
if interactive_mode:
print 'I am in interactive mode!'
else:
print 'I am in batch mode!'
然后用
python hello_world.py
I am in batch mode!
python -i hello_world.py
>> I am in interactive mode!