【发布时间】:2010-06-06 23:53:16
【问题描述】:
如何获取已导入进程的模块列表?
【问题讨论】:
标签: python python-module
如何获取已导入进程的模块列表?
【问题讨论】:
标签: python python-module
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
>>>
【讨论】:
如果您只想查看导入的模块(以及导入的顺序),也可以使用 -v 选项运行解释器
【讨论】: