One, Platform Module
Platform runs in the standard library, and it has a lot of functions that run our access to many system information.
>>> Import Platform
>>> Platform.uname ()
(' Linux ', ' gitlab.test.com ', ' 3.10.0-327.el7.x86_64 ', ' #1 SMP Thu Nov 22:10:57 UTC ', ' x86_64 ', ' x86_64 ')
>>> Platform.system ()
' Linux '
>>> Platform.release ()
' 3.10.0-327.el7.x86_64 '
>>> platform.linux_distribution ()
(' CentOS Linux ', ' 7.2.1511 ', ' Core ')
Extra:
The difference between importing Modules,import and From...import is that it simply says:
If you want to represent SYS.ARGV in the program with ARGV,
You can use: from sys import argv
Generally, you should avoid using from. Import and use the import statement,
Because it makes your program easier to read, it can also avoid conflicting names.
Second, PWD module
The Getpwall function returns a list of all the available user database portals that you can use to search for a user.
Three common functions of Getpwall Getpwnam Getpwuid
>>> pwd.getpwuid (0)
PWD.STRUCT_PASSWD (pw_name= ' root ', pw_passwd= ' x ', Pw_uid=0, pw_gid=0, pw_gecos= ' root ', pw_dir= '/root ', pw_shell= '/bin /bash ')
>>> pwd.getpwnam (' root ')
PWD.STRUCT_PASSWD (pw_name= ' root ', pw_passwd= ' x ', Pw_uid=0, pw_gid=0, pw_gecos= ' root ', pw_dir= '/root ', pw_shell= '/bin /bash ')
Python platform and PWD modules