hopeless-dream

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

python自动补全

查看python路径

>>> import sys
>>> sys.path
['', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7/site-packages', '/usr/lib64/python2.7/site-packages/gtk-2.0', '/usr/lib/python2.7/site-packages']

代码

复制代码
# cd /usr/lib/python2.7/site-packages/

# vim tab.py
#!/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
复制代码

导入模块测试

# python
Python 2.7.5 (default, Apr 11 2018, 07:36:10) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tab
>>> import subprocess
>>> subprocess.

 加入环境变量

# vim ~/.bashrc
export PYTHONSTARTUP=/usr/lib/python2.7/site-packages/tab.py


# . ~/.bashrc

 

posted on   hopeless-dream  阅读(61)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
点击右上角即可分享
微信分享提示