【发布时间】:2016-04-07 00:59:48
【问题描述】:
伙计们,我是 Python 新手,但我正在尝试使用 Python 获取我的 Windows 8 信息。但我无法这样做,我找不到以下代码的输出它什么都不显示。我正在使用 Netbeans。
# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.
if __name__ == "__main__":
import os
import re
def sys_info():
values = {}
cache = os.popen2("SYSTEMINFO")
source = cache[1].read()
sysOpts = ["Host Name", "OS Name", "OS Version", "Product ID", "System Manufacturer", "System Model", "System type", "BIOS Version", "Domain", "Windows Directory", "Total Physical Memory", "Available Physical Memory", "Logon Server"]
for opt in sysOpts:
values[opt] = [item.strip() for item in re.findall("%s:\w*(.*?)\n" % (opt), source, re.IGNORECASE)][0]
return values
if values == null :
print "yep"
print (values)
【问题讨论】:
-
sys_info 已定义但从未调用,因此没有可打印的内容
标签: python python-2.7