標籤:python
1. 建立Python環境變數設定檔:
vim ~/.pystartup
# Add auto-completion and a stored history file of commands to your Python# interactive interpreter. Requires Python 2.0+, readline. Autocomplete is# bound to the Esc key by default (you can change it - see readline docs).## Store the file in ~/.pystartup, and set an environment variable to point# to it: "export PYTHONSTARTUP=~/.pystartup" in bash.import atexitimport osimport readlineimport rlcompleterreadline.parse_and_bind('tab: complete')historyPath = os.path.expanduser("~/.pyhistory")def save_history(historyPath=historyPath): import readline readline.write_history_file(historyPath)if os.path.exists(historyPath): readline.read_history_file(historyPath)atexit.register(save_history)del os, atexit, readline, rlcompleter, save_history, historyPath
2.設定Python環境變數:
即時生效,重啟失效:export PYTHONSTARTUP=~/.pystartup
永久對目前使用者生效:echo "export PYTHONSTARTUP=~/.pystartup" >> ~/.bash_profile
著作權聲明:本文為博主原創文章,未經博主允許不得轉載。
設定python 命令列互動程式自動補齊