# python startup file
import readline
import rlcompleter
import atexit
import os
# tab completion
readline.parse_and_bind('tab: complete')
# history file
# win 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

将以上文件保存为.pythonstartup并存放在用户的主目录下,window放在C:\Users\Administrator下,linux放在/root或者/home/xxx目录下,然后设置环境变量

linux中export PYTHONSTARTUP=~/.pythonstartup

windows中一样,打开控制面板\系统和安全\系统,高级系统设置,环境变量,新建系统变量,变量名为PYTHONSTARTUP,变量值为之前的文件

python3中需要安装pyreadline,pip install pyreadline

 linux和window中需要修改下HOME,HOMEPATH

相关文章:

  • 2022-12-23
  • 2022-03-05
  • 2022-12-23
  • 2021-07-07
  • 2021-09-23
  • 2021-06-13
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-06
  • 2021-11-17
  • 2022-01-17
  • 2022-12-23
  • 2021-11-17
相关资源
相似解决方案