@Jweede链接
提供答案不准确。它应该是:
如何检索是否设置了交互/检查标志import osos.environ['PYTHONINSPECT'] = '1'
@Brian答案的另一种形式:
import osfrom ctypes import POINTER, c_int, cast, pythonapidef in_interactive_inspect_mode(): """Whether '-i' option is present or PYTHonINSPECT is not empty.""" if os.environ.get('PYTHONINSPECT'): return True iflag_ptr = cast(pythonapi.Py_InteractiveFlag, POINTER(c_int)) #NOTE: in Python 2.6+ ctypes.pythonapi.Py_InspectFlag > 0 # when PYTHonINSPECT set or '-i' is present return iflag_ptr.contents.value != 0
见Python的main.c中。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)