Python| os.uname() 方法
Python中的os.uname()方法用于获取有关当前操作系统的信息。该方法以类元组对象的属性形式返回当前操作系统的名称、版本和版本、网络上的机器名称和硬件标识符等信息。
Syntax: os.uname()
Parameters: Not required
Return Type: This method returns a tuple-like object which has five attributes:
- sysname – operating system name
- nodename – name of machine on network (implementation-defined)
- release – operating system release
- version – operating system version
- machine – hardware identifier
代码 #1:使用 os.uname() 方法
# Python program to explain os.uname() method
# importing os module
import os
# Get the information of current
# operating system
os_info = os.uname()
# print the information
print(os_info)
输出:
posix.uname_result(sysname='Linux', nodename='pppContainer', release='4.4.0-1075-aws',
version='#85-Ubuntu SMP Thu Jan 17 17:15:12 UTC 2019', machine='x86_64')