In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Python default tab completion command line, in interactive mode, as long as you write a small tab.py module; implementation code is as follows;
#!/ bin/env python # -*- coding: utf-8-*-# python startup file import sysimport readlineimport rlcompleteimport atexitiimport osimport platform# tab completion readline.parse_and_bind ('tab: complete')##This is to add historical commands to the file, in the respective home directory, if you do not need to log can delete if platform.system() == 'Windows': # history file ,os.environ Get user's home directory, this is win10, win7 system may need to change (see os.environ key for yourself) histfile = os.path.join(os.environ['USERPROFILE'], '.pythonhistory')else: # history file ,os.environ Get user's home directory histfile = os.path.join(os.environ['HOME'], '.pythonhistory')## end for history###try: readline.read_history_file(histfile)except IOError: passatexit.register(readline.write_history_file, histfile)del os, histfile, readline, rlcompleter
Copy the above code and save it to a py file (define the name yourself, and later you need to import this module under interaction), and put it into your py environment under the search path.
Start Python interaction
import xxx
And then you import any module and you test it.
How do you automatically import this module into Python when it starts? Under the PYTHONSTARTUP environment variable, add this module to this environment variable
If it is windows system, define it in your own user variables (my computer ==> properties ==> advanced ==> environment variables ==> user variables)
PYTHONSTARTUP corresponds to the path of the module you just saved
If you are linux, add export PYTHONSTARTUP=/xxx/xx/xx.py to your own user variable environment (/root/.bash_profile, or/etc/profile in the global variable)
Overload environment variables (under login again) can be tested
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.