• python


    import subprocess
    import re
    
    # info = subprocess.Popen("systeminfo",shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE).stdout.read().decode("gbk")
    #
    # with open(r"D:/info.txt",'w') as f:
    #     f.write(info)
    
    with open(r"D:/info.txt",'r') as f:
        info = f.read()
    
    info2 = re.sub("s","",info)
    # print(info2)
    
    #主机名:PC201808110908
    hostname = r"(?P<hostname>主机名Ww{2}d+)"
    
    #产品ID:00426-OEM-8992662-00006
    cp_id = r"(?P<cp_id>产品IDWd+-w+-d+-d+)"
    
    #初始安装日期:2018/8/11,9:15:36   d/dWd:d:d)
    cz_date = r"(?P<cz_date>初始安装日期Wd+Wd+Wd+Wd+:d+:d+)"
    
    #系统类型:x64-based
    sys_type = r"(?P<sys_type>系统类型Ww+d+-[a-z]+)"
    
    #处理器:安装了1个处理器。[01]:Intel64Family6Model58Stepping9GenuineIntel~2601Mhz
    cpu_type = r"(?P<Intel>Inteld+)(?P<Family>Familyd+)(?P<Model>Modeld+)(?P<Stepping>Steppingd+)(?P<GenuineIntel>GenuineIntelW+d+w{3})"
    
    #物理内存总量:8,142MB
    wl_mer = r"(?P<wl_mer>物理内存总量Wd+Wd+w{2})"
    
    #IP地址,MAC地址:IP地址[01]:192.168.1.3[02]:fe80::557c:e951:f509:995b
    ip_add = r"(?P<ip_add>IP地址[d+]Wd+Wd+Wd+Wd+)(?P<mac>[d+]W(?:w+|SW){9})"
    
    data_list = [hostname,cp_id,cz_date,sys_type,cpu_type,wl_mer,ip_add]
    
    c = []
    for i in data_list:
        b = re.finditer(i,info2).__next__().groupdict()
        c.append(b)
    
    with open('./PC_MSG.txt','w') as f2:
        f2.write(str(c))
  • 相关阅读:
    F
    E
    网上见到一同行发的隐私政策 备以后用
    Cannot connect to the Docker daemon. Is the docker daemon running on this host?
    mark
    转 随机数问题
    随机不同的数
    转 基于Quick-cocos2dx 2.2.3 的动态更新实现完整篇。(打包,服务器接口,模块自更新
    字符串
    关于cmbiling.jar cocos2dx的问题
  • 原文地址:https://www.cnblogs.com/Anec/p/9715658.html
Copyright © 2020-2023  润新知