python设置客户端UA
userAgent = platform.uname().system + " " + platform.uname().release + "(" + (platform.uname().node + " " + platform.uname().version + " " + platform.uname().machine) + ")"
输出
Darwin 21.3.0(bogon Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 x86_64)
python取OS信息
import platform #导入platform模块
print('操作系统名称:', platform.system()) #获取操作系统名称
print('操作系统名称及版本号:', platform.platform()) #获取操作系统名称及版本号
print('操作系统版本号:', platform.version()) #获取操作系统版本号
print('操作系统的位数:', platform.architecture()) #获取操作系统的位数
print('计算机类型:', platform.machine()) #计算机类型
print('计算机的网络名称:', platform.node()) #计算机的网络名称
print('计算机处理器信息:', platform.processor()) #计算机处理器信息
print('包含上面所有的信息汇总:', platform.uname())#包含上面所有的信息汇总
MAC输出:
操作系统名称: Darwin
操作系统名称及版本号: macOS-12.2-x86_64-i386-64bit
操作系统版本号: Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000
操作系统的位数: ('64bit', '')
计算机类型: x86_64
计算机的网络名称: bogon
计算机处理器信息: i386
包含上面所有的信息汇总: uname_result(system='Darwin', node='bogon', release='21.3.0', version='Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000', machine='x86_64')
Window输出
操作系统名称: Windows
操作系统名称及版本号: Windows-10-10.0.19044-SP0
操作系统版本号: 10.0.19044
操作系统的位数: ('64bit', 'WindowsPE')
计算机类型: AMD64
计算机的网络名称: LAPTOP-N6F0T5Q7
计算机处理器信息: Intel64 Family 6 Model 140 Stepping 1, GenuineIntel
包含上面所有的信息汇总: uname_result(system='Windows', node='LAPTOP-N6F0T5Q7', release='10', version='10.0.19044', machine='AMD64')
Linux输出
操作系统名称: Linux
操作系统名称及版本号: Linux-3.10.0-957.10.1.el7.x86_64-x86_64-with-centos-7.6.1810-Core
操作系统版本号: #1 SMP Mon Mar 18 15:06:45 UTC 2019
操作系统的位数: ('64bit', 'ELF')
计算机类型: x86_64
计算机的网络名称: cloud
计算机处理器信息: x86_64
包含上面所有的信息汇总: uname_result(system='Linux', node='cloud', release='3.10.0-957.10.1.el7.x86_64', version='#1 SMP Mon Mar 18 15:06:45 UTC 2019', machine='x86_64', processor='x86_64')
参考:https://blog.csdn.net/weixin_43545225/article/details/127194789