我做了一个Python获取电脑信息的程序,小部分代码是网上找的,
本来想把这个做成一个坑人小程序的 到后面没有灵感了
有想法的可以帮我做一下 私聊发代码给我
代码(pycharm运行通过)
# -*- coding: utf-8 -*-
import wmi
import sys
import time
import os
import platform
import socket
import uuid
# 获取主机名
hostname = socket.gethostname()
ip = socket.gethostbyname(hostname)
class Hardware:
@staticmethod
def get_cpu_sn():
"""
获取CPU序列号
:return: CPU序列号
"""
c = wmi.WMI()
for cpu in c.Win32_Processor():
# print(cpu.ProcessorId.strip())
return cpu.ProcessorId.strip()
@staticmethod
def get_baseboard_sn():
"""
获取主板序列号
:return: 主板序列号
"""
c = wmi.WMI()
for board_id in c.Win32_BaseBoard():
# print(board_id.SerialNumber)
return board_id.SerialNumber
@staticmethod
def get_bios_sn():
"""
获取BIOS序列号
:return: BIOS序列号
"""
c = wmi.WMI()
for bios_id in c.Win32_BIOS():
# print(bios_id.SerialNumber.strip)
return bios_id.SerialNumber.strip()
@staticmethod
def get_disk_sn():
"""
获取硬盘序列号
:return: 硬盘序列号列表
"""
c = wmi.WMI()
disk_sn_list = []
for physical_disk in c.Win32_DiskDrive():
# print(physical_disk.SerialNumber)
# print(physical_disk.SerialNumber.replace(" ", ""))
disk_sn_list.append(physical_disk.SerialNumber.replace(" ", ""))
return disk_sn_list
def start(cishu):
print("加载中.")
print("▏")
time.sleep(0.2)
os.system("cls")
print("加载中..")
print("▎")
time.sleep(0.2)
os.system("cls")
print("加载中...")
print("▍")
time.sleep(0.2)
os.system("cls")
print("加载中....")
print("▋")
time.sleep(0.2)
os.system("cls")
print("加载中.....")
print("▊")
time.sleep(0.2)
os.system("cls")
print("加载中......")
print("▉")
time.sleep(0.2)
os.system("cls")
print("加载中")
print("▉▏")
time.sleep(0.2)
os.system("cls")
print("加载中.")
print("▉▎")
time.sleep(0.2)
os.system("cls")
print("加载中..")
print("▉▍")
time.sleep(0.2)
os.system("cls")
print("加载中...")
print("▉▌")
time.sleep(0.2)
os.system("cls")
print("加载中....")
print("▉▋")
time.sleep(0.2)
os.system("cls")
print("加载中.....")
print("▉▊")
time.sleep(0.2)
os.system("cls")
print("加载中......")
print("▉▉")
time.sleep(0.2)
os.system("cls")
print("加载中.")
print("▉▉▏")
time.sleep(0.2)
os.system("cls")
print("加载中..")
print("▉▉▎")
time.sleep(0.2)
os.system("cls")
print("加载中...")
print("▉▉▍")
time.sleep(0.2)
os.system("cls")
print("加载中....")
print("▉▉▌")
time.sleep(0.2)
os.system("cls")
print("加载中.....")
print("▉▉▋")
time.sleep(0.2)
os.system("cls")
print("加载中......")
print("▉▉▊")
time.sleep(0.2)
os.system("cls")
print("加载中.")
print("▉▉▉▏")
time.sleep(0.2)
os.system("cls")
print("加载中..")
print("▉▉▉▎")
time.sleep(0.2)
os.system("cls")
print("加载中...")
print("▉▉▉▍")
time.sleep(0.2)
os.system("cls")
print("加载中...")
print("▉▉▉▌")
time.sleep(0.2)
os.system("cls")
print("加载中....")
print("▉▉▉▋")
time.sleep(0.2)
os.system("cls")
print("加载中....")
print("▉▉▉▋")
time.sleep(0.2)
os.system("cls")
print("加载中.....")
print("▉▉▉▊")
time.sleep(0.2)
os.system("cls")
print("加载中......")
print("▉▉▉▉")
time.sleep(0.2)
os.system("cls")
def get_mac_address():
mac=uuid.UUID(int = uuid.getnode()).hex[-12:]
return ":".join([mac[e:e+2] for e in range(0,11,2)])
if __name__ == '__main__':
start(5)
print()
print("正在获取电脑信息...")
time.sleep(2)
print("已成功!")
time.sleep(0.5)
if sys.platform=="win32":
print("操作系统:Windows")
time.sleep(0.5)
if sys.platform=="darwin":
print("操作系统:mac")
time.sleep(0.5)
print("CPU序列号:{}".format(Hardware.get_cpu_sn()))
time.sleep(0.5)
print("主板序列号:{}".format(Hardware.get_baseboard_sn()))
time.sleep(0.5)
print("Bios序列号:{}".format(Hardware.get_bios_sn()))
time.sleep(0.5)
print("硬盘序列号:{}".format(Hardware.get_disk_sn()))
time.sleep(0.5)
print("操作系统:",platform.architecture())
time.sleep(0.5)
print("机器类型:",platform.machine())
time.sleep(0.5)
print("网络名称:",platform.node())
time.sleep(0.5)
print("处理器名称:",end="")
print(platform.processor())
time.sleep(0.5)
print("主机名:",hostname)
time.sleep(0.5)
print("电脑ip:",ip)
time.sleep(0.5)
print("Mac地址:",get_mac_address())