Python:我的进程中导入了哪些模块?

Mar*_*son 3 python python-module

如何获取已导入到我的流程中的模块列表?

Joh*_*hin 11

sys.modules.values()...如果你真的需要模块的名称,请使用sys.modules.keys()

dir() 不是你想要的.

>>> import re
>>> def foo():
...     import csv
...     fubar = 0
...     print dir()
...
>>> foo()
['csv', 'fubar'] # 're' is not in the current scope
>>>
Run Code Online (Sandbox Code Playgroud)