Python os: Difference between revisions
From wikinotes
(Created page with "Python primarily stores information about the operating system in the <code>sys</code> and <code>platform</code> modules. = Operating System = <blockquote> <syntaxhighlight l...") |
(No difference)
|
Revision as of 20:39, 31 July 2021
Python primarily stores information about the operating system in the sys
and platform
modules.
Operating System
import sys import platform sys.platform # linux, linux2, FreeBSD, win32, darwin, ... if sys.platform.startswith('linux'): # ... platform.system() # Linux, Windows, ... platform.libc_ver()
Machine
import platform platform.node() # hostname platform.version() platform.uname() # kernel info