首頁>Club>
5
回覆列表
  • 1 # 使用者834195712159

    程式碼示例

    import wmi

    import os

    w = wmi.WMI()

    global list

    list=[]

    def info():

    list.append("電腦資訊")

    for BIOSs in w.Win32_ComputerSystem():

    list.append("電腦名稱: %s" %BIOSs.Caption)

    list.append("使 用 者: %s" %BIOSs.UserName)

    for address in w.Win32_NetworkAdapterConfiguration(ServiceName = "e1dexpress"):

    list.append("IP地址: %s" % address.IPAddress[0])

    list.append("MAC地址: %s" % address.MACAddress)

    for BIOS in w.Win32_BIOS():

    list.append("使用日期: %s" %BIOS.Description)

    list.append("主機板型號: %s" %BIOS.SerialNumber)

    for processor in w.Win32_Processor():

    list.append("CPU型號: %s" % processor.Name.strip())

    for memModule in w.Win32_PhysicalMemory():

    totalMemSize=int(memModule.Capacity)

    list.append("記憶體廠商: %s" %memModule.Manufacturer)

    list.append("記憶體型號: %s" %memModule.PartNumber)

    list.append("記憶體大小: %.2fGB" %(totalMemSize/1024**3))

    for disk in w.Win32_DiskDrive(InterfaceType = "IDE"):

    diskSize=int(disk.size)

    list.append("磁碟名稱: %s" %disk.Caption)

    list.append("磁碟大小: %.2fGB" %(diskSize/1024**3))

    for xk in w.Win32_VideoController():

    list.append("顯示卡名稱: %s" %xk.name)

    def main():

    global path

    path= "c:/systeminfo"

    for BIOSs in w.Win32_ComputerSystem():

    UserNames=BIOSs.Caption

    fileName=path+os.path.sep+UserNames+".txt"

    info()

    #判斷資料夾(路徑)是否存在

    if not os.path.exists(path):

    print("不存在")

    #建立資料夾(檔案路徑)

    os.makedirs(path)

    #寫入檔案資訊

    with open(fileName,"w+") as f:

    for li in list:

    print(li)

    l=li+" "

    f.write(l)

    else:

    print("存在")

    with open(fileName,"w+") as f:

    for li in list:

    print(li)

    l=li+" "

    f.write(l)

    main()

  • 中秋節和大豐收的關聯?
  • 今年出遊的時候遇到自己心愛的人,該怎麼向她變白?