1. 先準備一個tab.py的腳本
? shell> cat tab.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #!/usr/bin/python # python tab file ? ?import ?sys 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 |
2. 查看Python默認的模塊存放地址
1 2 3 4 5 6 7 | [root@localhost ~] # python Python? 2.6 . 6 ?(r266: 84292 , Nov? 22 ?2013 ,? 12 : 16 : 22 ) [GCC? 4.4 . 7 ?20120313 ?(Red Hat? 4.4 . 7 - 4 )] on linux2 Type ?"help" ,? "copyright" ,? "credits" ?or ?"license" ?for ?more information. >>>? import ?sys >>> sys.path [' ', ' / usr / lib64 / python26. zip ', ' / usr / lib64 / python2. 6 ', ' / usr / lib64 / python2. 6 / plat - linux2 ',? |
3. 拷貝該腳本到默認模塊存放路徑
1 | cp ?tab.py?? /usr/lib64/python2 .6/ |
4. 現在可以用了
本文轉自不要超過24個字符博客51CTO博客,原文鏈接http://blog.51cto.com/cstsncv/1917139如需轉載請自行聯系原作者
cstsncv