Python (Win)readline和tab补全的安装方法
作者:x024 时间:2021-07-30 16:04:46
最近开始学Python,想直接通过命令行的方式进行学习。
奈何没有Tab补全,操作实在麻烦,网上各种百度后无果(x64系统,x86的可以直接下载网上各种编译好的包)
最后自己百度+加上自己的摸索,找到了在64位系统下轻松安装readline和tab补全的方法
一、安装readline
cmd命令行,就会自动安装readline模块
python -m pip install pyreadline
二、编写tab.py
文件保存在..\Python\Lib\tab.py
例如:D:\Program Files\Python\Lib\tab.py
#python Tab
import sys
import readline
import rlcompleter
import atexit
import os
readline.parse_and_bind('tab: complete')
# windows
histfile = os.path.join(os.environ['HOMEPATH'], '.pythonhistory')
# linux
# 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
三、效果测试
使用import tab引入tab补全
import tab
四、常见问题
1. 同时安装python2.7 + python3.0
安装readline时使用:
python -2 -m pip install pyreadline
2. 提示readline不是DLL %1
请使用Python提供的命令安装,我就是下载网上编译好的readline模块就有这个问题。(使用第一步)
来源:https://blog.csdn.net/hx7013/article/details/63871940
标签:Python,readline,tab补全
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
CSS编写过程中常见的10个错误
2008-05-29 12:49:00
python如何在word中存储本地图片
2022-09-13 02:17:53
![](https://img.aspxhome.com/file/2023/3/68343_0s.png)
Keras中的多分类损失函数用法categorical_crossentropy
2023-06-23 12:25:37
![](https://img.aspxhome.com/file/2023/5/63935_0s.jpg)
看看那些名牌LOGO的成长史
2009-03-24 20:37:00
![](https://img.aspxhome.com/file/UploadPic/20093/24/1406370-34s.jpg)
谈非线性任务流程的窗口打开方式
2008-08-28 12:47:00
![](https://img.aspxhome.com/file/UploadPic/20088/28/2008828125458515s.jpg)
Python报错SyntaxError:unexpected EOF while parsing的解决办法
2023-10-01 10:29:54
JS完美实现对象克隆
2008-08-03 16:51:00
使用Python求解带约束的最优化问题详解
2022-06-28 18:38:19
![](https://img.aspxhome.com/file/2023/8/75258_0s.jpg)
解决Dreamweaver不支持中文文件名
2008-06-04 09:37:00
Web 标准设计实践:Google 的首页
2008-10-12 12:14:00
从SNS看社会化界面设计 I
2009-02-19 12:21:00
![](https://img.aspxhome.com/file/UploadPic/20092/19/01-43s.jpg)
ASP checkbox复选框是否被选中的代码(结合数据库)
2011-03-06 11:21:00
Web设计色彩速查表
2009-12-21 16:24:00
Django 中使用流响应处理视频的方法
2021-01-12 20:55:13
![](https://img.aspxhome.com/file/2023/7/65547_0s.png)
用 ASP 创建 GUID
2009-04-19 18:43:00
关于ASP循环表格的问题之解答[比较详细]
2011-04-08 11:14:00
php输出xml必须header的解决方法
2023-09-11 20:00:16
PyTorch搭建ANN实现时间序列风速预测
2022-11-28 23:38:28
![](https://img.aspxhome.com/file/2023/4/75364_0s.png)
开发iPhone版校友录
2009-08-31 16:29:00
用户是如何浏览你的网站的
2010-05-03 14:26:00
![](https://img.aspxhome.com/file/UploadPic/20105/3/eyetrack-74s.jpg)