一、首先打开python,观察python的安装路径
[root@localhost ~]# python
Python 3.6.2 (default,Aug 14 2017,22:12:34)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help","copyright","credits" or "license" for more information.
>>> import sys
>>> sys.path
['','/usr/local/lib/python36.zip','/usr/local/lib/python3.6','/usr/local/lib/python3.6/lib-dynload','/root/.local/lib/python3.6/site-packages','/usr/local/lib/python3.6/site-packages']
>>>
二、退出python、进入python目录
[root@localhost ~]# cd /usr/local/lib/python3.6/
[root@localhost python3.6]# vim tab.py
输入:
#!/usr/bin/env python
# python startup 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:
【更新地址】http://doublelinux.blog.51cto.com/12300166/1966544
pass
atexit.register(readline.write_history_file,histfile)
del os,histfile,readline,rlcompleter
四、验证
[root@localhost python3.6]# python
Python 3.6.2 (default,"credits" or "license" for more information.
>>> a
abs( all( and any( as ascii( assert
>>> b
bin( bool( break bytearray( bytes(
>>> c
callable( chr( class classmethod( compile( complex( continue
>>>
【更新地址】http://doublelinux.blog.51cto.com/12300166/1966544