Python Add Tab key function

Source: Internet
Author: User

When learning Python, how does not have the TAB key to complete the function, I feel that it will be a nightmare, for us this rookie, just contact Python, to all do not understand, fortunately have predecessors of guidance, study, and record down, have not learned this function small partners!

Environment:

[Email protected] ~]# cat/etc/centos-release
CentOS Linux release 7.4.1708 (Core)
[Email protected] ~]#

Specific process:

[Email protected] site-packages]#python #进入python
Python 2.7.5 (default, 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "Help", "copyright", "credits" or "license" for more information.
>>>Import sys #导入sys模块
>>>Sys.path #确认系统默认撸觉
[', '/usr/lib64/python27.zip ', '/usr/lib64/python2.7 ', '/usr/lib64/python2.7/plat-linux2 ', '/usr/lib64/python2.7/ Lib-tk ', '/usr/lib64/python2.7/lib-old ', '/usr/lib64/python2.7/lib-dynload ', '/usr/lib64/python2.7/site-packages ' , '/usr/lib/python2.7/site-packages ']
>>> exit ()
[Email protected] site-packages]# pwd#进入要放入tab the directory of the. py file (the path above, just put one), I prevent the following directory:
/usr/lib64/python2.7/site-packages

###########################################################

[email protected] site-packages]# cat tab.py
#!/usr/bin/env python
# Python startup 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

###########################################################

[[email protected] site-packages]# python
Python 2.7.5 (default, 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "Help", "copyright", "credits" or "license" for more information.
>>> Import Tab#使用前先导入tab模块
>>> Import Sys#下面就可以使用tab键了
>>> sys.
Sys.__class__ (sys.__sizeof__ (sys.copyright sys.getfilesystemencoding (sys.prefix
sys.__delattr__ (sys.__stderr__ sys.displayhook (Sys.getprofile (SYS.PS1
sys.__dict__ sys.__stdin__ sys.dont_write_bytecode Sys.getrecursionlimit (sys.ps2
sys.__displayhook__ (sys.__stdout__ sys.exc_clear (Sys.getrefcount (sys.py3kwarning
sys.__doc__ sys.__str__ (Sys.exc_info (sys.getsizeof (sys.pydebug
Sys.__excepthook__ (sys.__subclasshook__ (Sys.exc_type sys.gettrace (Sys.setcheckinterval (
Sys.__format__ (Sys._clear_type_cache (Sys.excepthook (sys.hexversion sys.setdlopenflags (
sys.__getattribute__ (Sys._current_frames (Sys.exec_prefix sys.long_info sys.setprofile (
Sys.__hash__ (Sys._debugmallocstats (sys.executable sys.maxint sys.setrecursionlimit (
Sys.__init__ (Sys._getframe (Sys.exit (Sys.maxsize sys.settrace (
sys.__name__ sys._mercurial Sys.exitfunc (Sys.maxunicode sys.stderr
sys.__new__ (sys.api_version sys.flags sys.meta_path Sys.stdin
sys.__package__ sys.argv sys.float_info sys.modules sys.stdout
sys.__reduce__ (sys.builtin_module_names sys.float_repr_style sys.path sys.subversion
sys.__reduce_ex__ (Sys.byteorder sys.getcheckinterval (sys.path_hooks sys.version
Sys.__repr__ (Sys.call_tracing (sys.getdefaultencoding (Sys.path_importer_cache sys.version_info
Sys.__setattr__ (Sys.callstats (sys.getdlopenflags (Sys.platform sys.warnoptions
>>> sys.

Python Add Tab key function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.