我有一个模块(tqdm),根据我是否在jupyter笔记本或jupyter lab环境中运行我的.ipynb
,需要以不同方式导入它。有没有办法在Python中确定这一点?例如:
if <jupyter notebook>:
from tqdm import tqdm_notebook as tqdm
elif <jupyter lab>:
from tqdm import tqdm
else:
print("Not in jupyter environment.")