Most of the system interfaces in Python are concentrated in two modules: SYS and OS. That's a little simplistic. There are also other table-to-module modules that fall into this area. They include:
Glob Extensions for file names
Socket for network connection and interprocess communication (IPC)
Threading,_threading,queue for running and synchronizing session concurrent threads
The Time,timeit is used to obtain system time-related details.
Subprocess,multiprocessing for starting and controlling parallel processes
Signal,select,shutil,tempfile for a variety of system-related tasks
There are also such as pyserial (a serial port interface), Pexpect (a class expect system for dialogue between control programs) and even twisted (a network framework) and so on third-party expansion packages are also classified into the field of system programming. Other built-in functions are actually system interfaces such as the Open function is the FileSystem interface but in general the SYS and OS modules together form the core of Python's built-in System tools
In principle, SYS is responsible for exporting components related to the Python interpreter itself (such as the module search path) The OS is not always so obvious in the variable and function practices that are included in Python's underlying operating system (e.g. SYS contains a standard input-output stream) But it can also be said that they are related to operating system patterns
Get module documentation
Learning to write a system in Python is largely about learning Python's system modules.
For example, we want to know that a built-in module exports everything can be read in the library book related items can also read its source code or interactively get its property list and document string
We import the Ptyhon3.1sys module to see what good things it has to offer us.
Microsoft Windows [version 6.1.7601]
Copyright (c) Microsoft Corporation. All rights reserved.
C:\users\administrator.win-20160322ksz>
C:\users\administrator.win-20160322ksz>d:
D:\>dir
The volume in drive D is the software
The serial number of the volume is 000f-9cf8
D:\ The directory
2016/07/03 21:43 6,862,200 1.zip
2016/09/14 11:17 1,325,052 CODE_SHORT.PCM
2016/08/21 13:20 Config.ini
2016/06/19 01:52 2,558 day6.py
2016/10/16 19:43 <DIR> Documents
2016/11/22 01:02 <DIR> Downloads
2016/03/21 19:45 <DIR> Favorites
2016/03/27 14:45 <DIR> Kuwo
2016/11/28 23:09 <DIR> Mozilla Firefox
2016/06/21 10:52 <DIR> PDF
2016/05/15 19:16 <DIR> pp Helper 2.0
2016/05/02 23:02 <DIR> Program Files
2004/07/03 09:48 139,264 Psicon.dll
2004/10/24 09:19 1,112 Psicon.reg
2016/06/25 22:31 198,296 Pyexpat.pyd
2016/05/22 20:53 <DIR> Python
2016/06/25 22:31 42,136 Python.exe
2016/06/25 22:31 52,376 Python3.dll
2016/06/25 22:31 3,931,288 Python35.dll
2016/06/25 22:31 2,257,578 Python35.zip
2016/06/25 22:31 42,136 Pythonw.exe
2016/06/25 22:31 pyvenv.cfg
2016/10/06 13:07 <DIR> Qqvipdownload
2016/11/22 15:10 <DIR> Qycache
2016/06/17 15:32 <DIR> Screenshots
2016/06/25 22:31 26,264 Select.pyd
2016/06/25 22:31 773,784 Sqlite3.dll
2016/08/21 19:11 <DIR> Thunder Network
2016/06/25 22:31 871,576 Unicodedata.pyd
2016/06/25 22:31 89,416 Vcruntime140.dll
2016/02/12 13:16 <DIR> Win7dock
2016/06/25 22:31 25,752 Winsound.pyd
2016/06/17 22:45 <DIR> xy Apple Assistant
2016/06/25 22:31 91,288 _bz2.pyd
2016/06/25 22:31 129,176 _ctypes.pyd
2016/06/25 22:31 321,176 _decimal.pyd
2016/06/25 22:31 199,832 _elementtree.pyd
2016/06/25 22:31 1,444,504 _hashlib.pyd
2016/06/25 22:31 152,728 _lzma.pyd
2016/06/25 22:31 38,552 _msi.pyd
2016/06/25 22:31 28,824 _multiprocessing.pyd
2016/06/25 22:31 41,112 _overlapped.pyd
2016/06/25 22:31 72,344 _socket.pyd
2016/06/25 22:31 78,488 _sqlite3.pyd
2016/06/25 22:31 2,044,056 _ssl.pyd
2016/09/11 22:38 <DIR> Common software
2016/03/22 20:31 <DIR> League of Legends
2016/03/22 22:15 466 Software (D). lnk
31 Files 21,283,375 bytes
17 Directories 113,867,571,200 bytes available
D:\>python
Python 3.5.2 (V3.5.2:4DEF2A2901A5, June, 22:18:55) [MSC v.1900
D64)] on Win32
Type "Help", "copyright", "credits" or "license" for more information.
>>> Import Sys
>>> dir (SYS)
[' __displayhook__ ', ' __doc__ ', ' __excepthook__ ', ' __interactivehook__ ', ' __loade
R__ ', ' __name__ ', ' __package__ ', ' __spec__ ', ' __stderr__ ', ' __stdin__ ', ' __stdou '
T__ ', ' _clear_type_cache ', ' _current_frames ', ' _debugmallocstats ', ' _getframe ',
' _home ', ' _mercurial ', ' _xoptions ', ' api_version ', ' argv ', ' base_exec_prefix ', '
Base_prefix ', ' builtin_module_names ', ' byteorder ', ' call_tracing ', ' callstats ',
' Copyright ', ' displayhook ', ' dllhandle ', ' dont_write_bytecode ', ' exc_info ', ' exc
Epthook ', ' exec_prefix ', ' executable ', ' exit ', ' flags ', ' float_info ', ' Float_rep
R_style ', ' get_coroutine_wrapper ', ' getallocatedblocks ', ' getcheckinterval ', ' ge
Tdefaultencoding ', ' getfilesystemencoding ', ' getprofile ', ' getrecursionlimit ', '
Getrefcount ', ' getsizeof ', ' getswitchinterval ', ' gettrace ', ' getwindowsversion ',
' Hash_info ', ' hexversion ', ' implementation ', ' int_info ', ' Intern ', ' Is_finalizi
Ng ', ' maxsize ', ' maxunicode ', ' meta_path ', ' modules ', ' path ', ' path_hooks ', ' Pat
H_importer_cache ', ' platform ', ' prefix ', ' ps1 ', ' ps2 ', ' set_coroutine_wrapper ',
' Setcheckinterval ', ' setprofile ', ' setrecursionlimit ', ' setswitchinterval ', ' Set
Trace ', ' stderr ', ' stdin ', ' stdout ', ' thread_info ', ' Version ', ' Version_info ', '
Warnoptions ', ' winver ']
>>>
The Dir function simply returns a list that contains the string names of all the properties with the attribute formation. This is a convenient way to wake up the module at an interactive prompt
For example, there is a version in the result of the Dir function we have to know that there is a sys.version
>>>sys.__doc__ built-in module __doc__ word nginx: The return value is as follows
"This module provides access to some objects used or maintained by The\ninterpre
ter and to functions this interact strongly with the interpreter.\n\ndynamic obj
ECTS:\N\NARGV-command line arguments; ARGV[0] is the script pathname if known
\npath-Module search path; PATH[0] is the script directory, Else ' \nmodules
--Dictionary of Loaded Modules\n\ndisplayhook--called to show results in an I
Nteractive Session\nexcepthook--called to handle any uncaught exception other
than systemexit\n to customize printing in a interactive session or to install
A custom\n top-level exception handler, assign other functions to replace thes
E.\n\nstdin-Standard input file object; Used by input () \nstdout – Standard O
Utput file object; Used by print () \nstderr – standard Error object; Used for ER
Ror messages\n by assigning other file objects (or objects, behave like fil
es) \ n to these, it's possible to redirect all of the interpreter ' s I/o.\n\nlas
T_type--type of last uncaught exception\nlast_value--value of the last uncaught
Exception\nlast_traceback--Traceback of last uncaught exception\n these three
is only available in a interactive session after a\n Traceback have been prin
Ted.\n\nstatic Objects:\n\nbuiltin_module_names--tuple of module names built I
Nto this interpreter\ncopyright--copyright notice pertaining to this interpret
Er\nexec_prefix--Prefix used to find the machine-specific Python library\nexec
Utable--Absolute path of the executable binary of the Python Interpreter\nfloa
T_info--A struct sequence with information about the float IMPLEMENTATION.\NFL
Oat_repr_style--string indicating the style of repr () output for Floats\nhash_
Info--A struct sequence with information about the hash algorithm.\nhexversion
--Version information encoded as a single integer\nimplementation--Python IM
Plementation Information.\nint_info--a struct sequence with information about
The int implementation.\nmaxsize--the largest supported length of containers.\
Nmaxunicode--The value of the largest Unicode code Point\nplatform--platform
Identifier\nprefix--Prefix used to find the Python library\nthread_info--A
struct sequence with information about the thread implementation.\nversion--th
E version of this interpreter as a string\nversion_info--version information A
s a named Tuple\ndllhandle--[Windows only] integer handle of the Python DLL\NW
Inver--[Windows only] version number of the Python dll\n__stdin__--The Origi
NAL stdin; Don ' t touch!\n__stdout__-the original stdout; Don ' t touch!\n__stde
RR__-the original stderr; Don ' t touch!\n__displayhook__--the original DISPL
Ayhook; Don ' t touch!\n__excepthook__-the original excepthook; Don ' t touch!\n\
Nfunctions:\n\ndisplayhook ()--Print an object to the screens, and save it in BU
Iltins._\nexcepthook ()--print an exception and its traceback to Sys.stderr\nex
C_info ()--return thread-safe information about the current exception\nexit ()-
-Exit the interpreter by raising Systemexit\ngetdlopenflags ()--Returns flags
To is used for Dlopen () Calls\ngetprofile ()--Get the global profiling function
\ngetrefcount ()--Return the reference count for a object (plus one:-) \ngetre
Cursionlimit ()--return the max recursion depth for the interpreter\ngetsizeof (
)--Return the size of an object in Bytes\ngettrace ()--Get the global debug T
Racing Function\nsetcheckinterval ()--control how often the interpreter checks
For Events\nsetdlopenflags ()--set the ' flags to ' used for Dlopen () Calls\nset
Profile ()--Set the global profiling Function\nsetrecursionlimit ()--Set the M
Ax recursion depth for the interpreter\nsettrace ()--Set the global debug Traci
Ng function\n "
>>>
>>>pirnt (sys.__doc__)
This module provides access to some objects that are used or maintained
Interpreter and the ability to interact with the interpreter.
The print () built-in function correctly interprets line breaks Unfortunately, the page scrolling or pagination display is not done by itself, so there are still unsatisfactory displays on some platforms other tools like built-in Help (functions) do well
>>> Help (SYS)
Help on built-in module SYS:
NAME
Sys
MODULE REFERENCE
Https://docs.python.org/3.5/library\sys.html
The following documentation is automatically generated from the Python
source files. It is incomplete, incorrect or include features that
is considered implementation detail and may vary between Python
Implementations. When in doubt, consult the module reference at the
Location listed above.
DESCRIPTION
This module provides access to some objects used or maintained by the
Interpreter and to functions this interact strongly with the interpreter.
Dynamic objects:
ARGV-command line arguments; ARGV[0] is the script pathname if known
Path-module search path; PATH[0] is the script directory, Else '
Modules--Dictionary of Loaded modules
--More--
The Help function is one of the interfaces provided by the PYDOC system Pydoc system is a Python-brought standard library code that renders object-related documents into a formatted form this format can be a Unix-like manual that is handy for helping with the use of books and manuals before the last trick.
Python system modules