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)
精彩评论