# python startup file 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: 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,变量值为之前的文件
在python2中可以运行
原文地址:https://www.cnblogs.com/lgh344902118/p/8521437.html
时间: 2024-10-10 04:07:32