system:red Hat Enterprise Linux Server release 5.6 (Tikanga)
1. Get the Python directory
[Email protected] ~]# Pythonpython 2.4.3 (#1, Dec, 17:24:35) [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on Linux2typ E "Help", "copyright", "credits" or "license" for more information.>>> import sys>>> sys.path[", '/usr/ Lib64/python24.zip ', '/usr/lib64/python2.4 ', '/usr/lib64/python2.4/plat-linux2 ', '/usr/lib64/python2.4/lib-tk ', '/ Usr/lib64/python2.4/lib-dynload ', '/usr/lib64/python2.4/site-packages ', '/usr/lib64/python2.4/site-packages/ Numeric ', '/usr/lib64/python2.4/site-packages/gtk-2.0 ', '/usr/lib/python2.4/site-packages ']
Learn about the Python directory/usr/lib64/python2.4
2. Switch to the Python directory to write startup.py scripts to process Python <tab> events
The contents are as follows:
[[email protected] ~]# Cd/usr/lib64/python2.4/[[email protected] python2.4]# vi startup.py #!/usr/bin/python# python STA Rtup fileimport sysimport readlineimport rlcompleterimport atexitimport os# tab completionreadline.parse_and_bind (' tab : Complete ') # History filehistfile = Os.path.join (os.environ[' HOME '), '. Pythonhistory ') Try:readline.read_history_ File (histfile) except IOError:passatexit.register (Readline.write_history_file, histfile) del os, Histfile, ReadLine, Rlcompleter
3. Switch to the main directory to add the environment variable and make it effective
[[email protected] python2.4]# cd[[email protected] ~]# vi. BASHRC #在最后一行添加: #for pythonexport pythonstartup=/usr/lib64/ python2.4/startup.py
[[email protected] ~]# source. BASHRC
4. Verification
[Email protected] ~]# Pythonpython 2.4.3 (#1, Dec, 17:24:35) [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on Linux2typ E "Help", "copyright", "credits" or "license" for more information.>>> import sys>>> Sys.pathsys.path Sys.path_importer_cachesys.path_hooks >>> Sys.path
This article is from the "Legendary Library sub" blog, please be sure to keep this source http://chason.blog.51cto.com/9078447/1610304
Python command line Add Tab key Auto complete