查看python环境的一些知识点

1 查看python中的查找模块的路径

import sys
sys.path
['',
 '/usr/bin',
 '/usr/lib64/python26.zip',
 '/usr/lib64/python2.6',
 '/usr/lib64/python2.6/plat-linux2',
 '/usr/lib64/python2.6/lib-tk',
 '/usr/lib64/python2.6/lib-old',
 '/usr/lib64/python2.6/lib-dynload',
 '/usr/lib64/python2.6/site-packages',
 '/usr/lib64/python2.6/site-packages/gtk-2.0',
 '/usr/lib/python2.6/site-packages',
 '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info',
 '/usr/lib/python2.6/site-packages/IPython/extensions']


2 查看一个模块的具体路径

方法1: 利用__file__属性

import MySQLdb
 MySQLdb.__file__
'/usr/lib64/python2.6/site-packages/MySQLdb/__init__.pyc'


方法二:利用sys模块的modules方法

import sys
sys.modules['MySQLdb']
<module 'MySQLdb' from '/usr/lib64/python2.6/site-packages/MySQLdb/__init__.pyc'>


你可能感兴趣的:(python,环境,查看)