readline.parse_and_bind("tab: complete")
[root@dqz ~]# python
Python 2.7.8 (default, Oct 17 2014, 21:36:24)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tab
>>>
但是换个目录(也就是没有tab.py文件)的目录又不可以加载,那是因为它找不到tab文件,就像这样
[root@dqz site-packages]# python
Python 2.7.8 (default, Oct 17 2014, 21:36:24)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tab
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named tab
>>>
可以这样
>>>import sys
>>>sys.path
'/usr/local/python27/lib/python2.7/site-packages' 将tab.py放在该下就可以再任何目录下加载模块,哈哈!