文章目录
python获取本机IP、mac地址(物理地址)、计算机名物理地址计算机名、ip地址硬盘序列号 CPU序列号 主板序列号 bios序列号bios uuid号
python获取本机IP、mac地址(物理地址)、计算机名
物理地址
import uuid
def get_mac_address():
"""
获取本机物理地址,获取本机mac地址
:return:
"""
mac
=uuid
.UUID
(int = uuid
.getnode
()).hex[-12:].upper
()
return "-".join
([mac
[e
:e
+2] for e
in range(0,11,2)])
if __name__
== '__main__':
mac
= get_mac_address
()
print('本机物理地址:',mac
)
计算机名、ip地址
import socket
def get_computer_name_ip():
"""
python获取 电脑名、ip地址
:return:
"""
name
= socket
.getfqdn
(socket
.gethostname
())
addr
= socket
.gethostbyname
(name
)
return name
,addr
if __name__
== '__main__':
myname
,myaddr
= get_computer_name_ip
()
print('电脑名:',myname
)
print('ip地址:',myaddr
)
硬盘序列号 CPU序列号 主板序列号 bios序列号
import wmi
c
= wmi
.WMI
()
for physical_disk
in c
.Win32_DiskDrive
():
print("硬盘序列号", physical_disk
.SerialNumber
)
for cpu
in c
.Win32_Processor
():
print("CPU序列号", cpu
.ProcessorId
.strip
())
for board_id
in c
.Win32_BaseBoard
():
print("主板序列号", board_id
.SerialNumber
)
for mac
in c
.Win32_NetworkAdapter
():
print("mac地址", mac
.MACAddress
)
for bios_id
in c
.Win32_BIOS
():
print("bios序列号", bios_id
.SerialNumber
.strip
())
bios uuid号
"""
@Introduce : 获取 bios-uuid
@File : bios_uuid.py
@Time : 2020-12-10 16:43
@Author : xia hua dong
@Tel : 173 179 76823
@Email : 17317976823@163.com
@pip : pip install
"""
import platform
import subprocess
if platform
.system
() == 'Windows':
print('Windows系统')
(status
, BIOS_uuid
) = subprocess
.getstatusoutput
("wmic csproduct get UUID")
BIOS_uuid
= BIOS_uuid
.replace
("UUID", "")
BIOS_uuid
= BIOS_uuid
.replace
("\n", "")
BIOS_uuid
= BIOS_uuid
.replace
(" ", "")
print("主板BIOS_uuid:", BIOS_uuid
)
elif platform
.system
() == 'Linux':
print('Linux系统')
(status
, BIOS_uuid
) = subprocess
.getstatusoutput
("dmidecode -s system-uuid")
print("主板BIOS_uuid:", BIOS_uuid
)
else:
print('其他系统')
转载请注明原文地址:https://ipadbbs.8miu.com/read-42509.html