【发布时间】:2012-08-11 15:55:45
【问题描述】:
可能重复:
tell whether python is in -i mode
Tell if python is in interactive mode
有没有办法使用交互式选项 -i 来检查 python 脚本是否已运行?
例如
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!
【问题讨论】:
标签: python