This is a core module in Python
sys
is a core module. It's one of the very deep core modules, providing very useful information.
Attributes[]
platform
[]
The platform which the Python interpreter is running on.
version
[]
The version of the Python interpreter.
>>>import sys
>>>sys.version
'%PYTHON_VERSION% (tags/%TAGS%, %DATE%, %TIME%) [%DRIVER%]'
>>>
argv
[]
Returns the file that your script is running in.
>>>import sys
>>>sys.argv
['']
>>>sys.argv[0]
''
>>>
executable
[]
Returns the full (absolute) path to current Python interpreter. If path cannot be retrieved, an empty string or None
.
On Windows, sys.executable
returns something like this:
>>> sys.executable
'C:\\Users\\Andrew\\AppData\Local\\Programs\\Python\\Python39\\python.exe'
>>>
winver
[]
Windows only: Returns the type of python installation installed, along with the architecture. Example:
>>>import sys
>>>sys.winver
'3.9-64'
>>>
Functions[]
exit(arg)
[]
Exits the interpreter by raising SystemExit. Optionally accepts an integer argument arg
, identifying an exit status. If not specified, defaults to 0.
This is a short article. Please extend it!