After the test, I started to study Python advanced programming.
Those who have used zsh will surely be impressed with its automatic complementing function. Similar functions can be achieved through simple custom Python interactive command lines. The specific operations are as follows:
- Create the ". pythonstartup" file in the user directory and write the following content:
# Python Startup File Import Readline Import Rlcompleter Import Atexit Import OS # Tab completion Readline. parse_and_bind ( ' Tab: complete ' ) # History File Historyfile = OS. Path. Join (OS. Environ [ ' Home ' ], ' . Pythonstartup ' ) Try : Readline. read_history_file (historyfile) Except : Pass Atexit. Register (Readline. write_history_file, historyfile) Del OS, historyfile, Readline, rlcompleter
- Add environment variables, edit the. bashrc or. zshrc file (determined by your shell), and add the following content:
Export pythonstartup ="/Home/ma6174/. pythonstartup"
- Open the terminal and go to the python interactive command line interface. Below is my running effect: