Python platform and PWD modules

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.