In [1]: import importlib
In [2]: importlib.import_module('sys')
Out[2]: <module 'sys' (built-in)>
In [3]: a=importlib.import_module('sys')
In [4]: a.path
Out[4]:
['',
'/home/fhp/.local/bin',
'/usr/lib/python35.zip',
'/usr/lib/python3.5',
'/usr/lib/python3.5/plat-x86_64-linux-gnu',
'/usr/lib/python3.5/lib-dynload',
'/home/fhp/.local/lib/python3.5/site-packages',
'/usr/local/lib/python3.5/dist-packages',
'/usr/lib/python3/dist-packages',
'/home/fhp/.local/lib/python3.5/site-packages/IPython/extensions',
'/home/fhp/.ipython']
In [5]: getattr(a,'path')
Out[5]:
['',
'/home/fhp/.local/bin',
'/usr/lib/python35.zip',
'/usr/lib/python3.5',
'/usr/lib/python3.5/plat-x86_64-linux-gnu',
'/usr/lib/python3.5/lib-dynload',
'/home/fhp/.local/lib/python3.5/site-packages',
'/usr/local/lib/python3.5/dist-packages',
'/usr/lib/python3/dist-packages',
'/home/fhp/.local/lib/python3.5/site-packages/IPython/extensions',
'/home/fhp/.ipython']
importlib
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。