开发者

Python: what modules have been imported in my process?

How can I get a list of the modules that have been imported into my开发者_如何学运维 process?


sys.modules.values() ... if you really need the names of the modules, use sys.modules.keys()

dir() is not what you want.

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


You can also run the interpreter with -v option if you just want to see the modules that are imported (and the order they are imported in)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜