It is convenient to check the Python method with tab completion in peacetime.
- 1. The Mac platform is configured as follows:
- Mac is a Unix-like platform that needs to add a configuration to Bash_profile (default is no this file, you can create a new one under the host directory)
- View the Python interpreter path for the current system
Python2.7.6(v2.7.6: 3a1db0d2747e, NovTen -,xx: the: Wu) [GCC4.2.1(Apple Inc. Build5666) (dot3)] on Darwintype" Help","Copyright","credits"Or"License" for Moreinformation.>>>Import SYS>>>sys.path["','/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/ Beautifulsoup4-4.4.1-py2.7.egg','/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/requests-2.9.0-py2.7.egg ','/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/testkit_ Lite-3.1.14-py2.7.egg','/library/python/2.7/site-packages/pip-9.0.1-py2.7.egg','/library/frameworks/python.framework/versions/2.7/lib/python27.zip','/library/frameworks/python.framework/versions/2.7/lib/python2.7','/library/frameworks/python.framework/versions/2.7/lib/python2.7/plat-darwin','/library/frameworks/python.framework/versions/2.7/lib/python2.7/plat-mac','/library/frameworks/python.framework/versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages','/LIBRARY/FRAMEWORKS/PYTHON.FRAMEWORK/VERSIONS/2.7/LIB/PYTHON2.7/LIB-TK','/library/frameworks/python.framework/versions/2.7/lib/python2.7/lib-old','/library/frameworks/python.framework/versions/2.7/lib/python2.7/lib-dynload','/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages','/library/python/2.7/site-packages']
- Copy the newly-created tab.py file to the interpreter path, usually placed under the '/library/python/2.7/site-packages/' directory
- sudo cp tab.py/library/python/2.7/site/packages/
- Writes information about the configuration file to ~/.bash_profile if it exists, adds it to the file content, and creates a new file if it does not exist
Then go to Python Import tab with tab to list the following sub-methods
Python2.7.6(v2.7.6: 3a1db0d2747e, NovTen -,xx: the: Wu) [GCC4.2.1(Apple Inc. Build5666) (dot3)] on Darwintype" Help","Copyright","credits"Or"License" for Moreinformation.>>>Import Tab,sys>>>sys. Display All101Possibilities? (Y or N) sys.__class__ (sys.__hash__ (sys.__sizeof__ (sys.callstats (SYS). Getfilesystemencoding (Sys.prefix sys.__class__ (sys.__init__ (sys.__stderr__ Sys.copyright Sys.getprofile (Sys.ps1 sys.__class__ (sys.__i nit__ (sys.__stdin__ sys.displayhook (Sys.getrecursionlimit (sys.ps2 sys.__delattr__ (sys.__name__ sys.__stdout__ sys.dont_write_bytecode sys.getre Fcount (sys.py3kwarning sys.__delattr__ (sys.__new__ (sys.__str__ ( Sys.exc_clear (Sys.getsizeof (Sys.setcheckinterval (sys.__dict__ sys.__new__ ( Sys.__str__ (Sys.exc_info (Sys.gettrace (Sys.setdlopenflags ( SYS.__DISPLAYHOOK__ ( sys.__package__ sys.__subclasshook__ (Sys.exc_type sys.hexversion sys.setprof Ile (sys.__doc__ Sys.__plen sys.__subclasshook__ (Sys.excepthook ( Sys.long_info Sys.setrecursionlimit (sys.__doc__ sys.__reduce__ (Sys._clear_typ E_cache (Sys.exec_prefix sys.maxint sys.settrace (sys.__doc__ sy s.__reduce__ (Sys._current_frames (sys.executable sys.maxsize Sys.stderr Sys.__egginsert sys.__reduce_ex__ (Sys._getframe (Sys.exit (SYS). Maxunicode Sys.stdin sys.__excepthook__ (sys.__reduce_ex__ (sys._mercurial Sys.flags sys.meta_path sys.stdout sys.__format__ (sys.__r EPR__ (sys.Api_version sys.float_info sys.modules sys.subversion sys.__format__ ( sys.__repr__ (sys.argv sys.float_repr_style sys.path sys.ve Rsion sys.__getattribute__ (sys.__setattr__ (Sys.builtin_module_names sys.getcheckinterval ( Sys.path_hooks sys.version_info sys.__getattribute__ (sys.__setattr__ (Sys.byteo Rder sys.getdefaultencoding (Sys.path_importer_cache sys.warnoptions sys.__hash__ ( Sys.__sizeof__ (Sys.call_tracing (Sys.getdlopenflags (sys.platform>>> sys.
2.Ubuntu system configuration file and Mac is a little different, also write a tab.py file to the Python interpreter path, the other operation is not used, add the following code:
sudo VI /usr/lib/python2. 7/dist-packages/tab.pyimport sys,readline,rlcompleter,atexit,osreadline.parse_and_bind (' tab:complete'= 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
Python add tab completion