Win10下Python命令tab自動補全
環境:win10 64位 python 2.7.10
1.安裝pyreadline-master 已經編譯
進入安裝目錄 pyreadline-master
c:\Python27\python.exe setup.py install
2.在庫路徑 C:\Python27\Lib 新增python自動補全功能tab.py
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['HOMEPATH'
try:
readline.read_history_file(histfile)
except IOError:
pass
atexit.register(readline.write_history_file, histfile)
del os, histfile, readline, rlcompleter
注:win 下寫成 HOMEPATH linux 下HOME 否則會報錯
>>> import tab
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\tab.py", line 10, in <module>
histfile = os.path.join(os.environ['HOME'], '.pythonhistory')
File "C:\Python27\lib\os.py", line 425, in __getitem__
return self.data[key.upper()]
KeyError: 'HOME'
3.測試
>>> import os
>>> import tab
>>> os.
os.F_OK os._execvpe( os.getcwd( os.stat(
os.O_APPEND os._exists( os.getcwdu( os.stat_float_times(
os.O_BINARY os._exit( os.getenv( os.stat_result(
os.O_CREAT os._get_exports_list( os.getpid( os.statvfs_result(
os.O_EXCL os._make_stat_result( os.isatty( os.strerror(
os.O_NOINHERIT os._make_statvfs_result( os.kill( os.sys
os.O_RANDOM os._pickle_stat_result( os.linesep os.system(
os.O_RDONLY os._pickle_statvfs_result( os.listdir( os.tempnam(
os.O_RDWR os.abort( os.lseek( os.times(
os.O_SEQUENTIAL os.access( os.lstat( os.tmpfile(
os.O_SHORT_LIVED os.altsep os.makedirs( os.tmpnam(
os.O_TEMPORARY os.chdir( os.mkdir( os.umask(
os.O_TEXT os.chmod( os.name os.unlink(