即你能做类似的事情吗:
if we_are_in_ipython:
do_some_ipython_specific_stuff()
normal_python_stuff()
我想我想做的是非常松散地沿着 C# 中的 #if DEBUG
行(即使用 ipython 作为调试工具和命令行 python 来运行代码而不进行调试里面的东西)。
最佳答案
检查 __IPYTHON__
变量:
def is_ipython():
try:
__IPYTHON__
return True
except:
return False
关于python - 是否可以知道您是否在 ipython 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9093514/