
正文
python---硬件序列号
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示

安装wmi :
pip install wmi -i https://pypi.douban.com/simple
还要安装 pip install pywin32
import wmic = wmi.WMI()
zuban=c.Win32_BaseBoard()[0].SerialNumber.strip() #获取主板序列号
#BSN12345678901234567cpu=c.Win32_Processor()[0].ProcessorId.strip() #获取cpu序列号
#BFEBFBFF000306A9yinpan=c.Win32_DiskDrive()[0].SerialNumber.strip() #硬盘序列号
#S2Y4J9ADA29166neicun=c.Win32_PhysicalMemory()[0].SerialNumber.strip() #内存序列号
#E3806262#网卡mac地址:
def macAddress():#获取网卡mac信息函数
macs = []
for n in c.Win32_NetworkAdapter():
mactmp = n.MACAddress
if mactmp and len(mactmp.strip()) > 5:
tmpmsg = {}
tmpmsg['MACAddress'] = n.MACAddress
tmpmsg['Name'] = n.Name
tmpmsg['DeviceID'] = n.DeviceID
tmpmsg['AdapterType'] = n.AdapterType
tmpmsg['Speed'] = n.Speed
macs.append(tmpmsg)
return macs[0]['MACAddress'] #返回第一个网卡的mac地址【24:FD:52:3C:ED:8F】。macs包含所有网卡信息m=macAddress()print(cpu)
print(zuban)
print(yinpan)
print(neicun)
print(m)
获取mac地址
import uuid
x = uuid.getnode() #获取十进制的mac地址
#<class 'int'> 128437435448900







