Python3.6.5
以this answer为指南,我try 查看是否导入了一些模块,如math
.
但Python告诉我,它们都是进口的,而实际上它们不是进口的.
>>> import sys
>>> 'math' in sys.modules
True
>>> 'math' not in sys.modules
False
>>> math.pi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'math' is not defined
>>> import math
>>> 'math' in sys.modules
True
>>> math.pi
3.141592653589793