2010-06-06 49 views

回答

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 
>>> 
4

您也可以运行与-v选项的解释,如果你只是想看看那些进口的模块(和它们进口的顺序)