美文网首页
2021-02-19 Linux python 自动补齐

2021-02-19 Linux python 自动补齐

作者: 汪小静 | 来源:发表于2021-02-19 15:53 被阅读0次

参考:Python shell自动补齐_orends的专栏-CSDN博客_python shell 自动补全
Python实现Tab自动补全和历史命令管理的方法

利用readline和rlcompleter两个包

1. 获取python目录

import sys
sys.path

2.准备startup.py的脚本

# This is python shell startup script                               
# for Tab auto complete
print("Python start up...")
import readline
import rlcompleter
readline.parse_and_bind("tab: complete")

3. 将准备好的startup.py 放在python目录中

4.切换主目录后添加python环境变量

cd
vi .bashrc

添加:

#for python
export PYTHONSTARTUP=/usr/lib/python3.9/startup.py

5.配置环境变量生效

[~$]source .bashrc

6.进入python开始tab补齐之旅吧~~~~

~$ python
Python 3.9 | packaged by conda-forge | (default, Jan 26 2021, 01:34:10) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
Python start up...

相关文章

网友评论

      本文标题:2021-02-19 Linux python 自动补齐

      本文链接:https://www.haomeiwen.com/subject/scuaxltx.html