发布时间:2019-09-12 07:55:10编辑:auto阅读(1448)
1.准备一个脚本如下:
#!/usr/bin/python # python tab file import sys import readline import rlcompleter import atexit import os # tab completion readline.parse_and_bind('tab: complete') # history file histfile = os.path.join(os.environ['HOME'], '.pythonhistory') try: readline.read_history_file(histfile) except IOError: pass atexit.register(readline.write_history_file, histfile) del os, histfile, readline, rlcompleter
2.查看Python默认的模块存放地址
>>> import sys >>> sys.path ['', '/usr/local/python2.7/lib/python2.7/site-packages/distribute-0.6.49-py2.7.egg', '/usr/local/python2.7/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg', '/usr/local/python2.7/lib/python27.zip', '/usr/local/python2.7/lib/python2.7', '/usr/local/python2.7/lib/python2.7/plat-linux2', '/usr/local/python2.7/lib/python2.7/lib-tk', '/usr/local/python2.7/lib/python2.7/lib-old', '/usr/local/python2.7/lib/python2.7/lib-dynload', '/usr/local/python2.7/lib/python2.7/site-packages', '/usr/local/python2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']
3. 创建该脚本到默认模块存放路径
vi /usr/local/python2.7/lib/python2.7/tab.py
4导入tab模块,验证.
>>> import tab >>> sys. sys.__class__( sys.api_version sys.hexversion sys.__delattr__( sys.argv sys.long_info
上一篇: Python 中psutil 模块的安装
下一篇: python的字符转换常见bug
47848
46402
37290
34738
29321
25977
24922
19955
19549
18032
5796°
6420°
5936°
5965°
7071°
5919°
5950°
6444°
6407°
7786°