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!