开发者

Python: what modules have been imported in my process?

开发者 https://www.devze.com 2023-01-02 06:40 出处:网络
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()

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

精彩评论

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