请用puyhon写一个 获取系统版本,安全软件,IP的脚本

动态 未结 0 73
小小草
小小草 LV1 2023年9月23日 23:40 发表
以下是一个获取系统版本、安全软件和IP地址的Python脚本: ```python import platform import subprocess # 获取操作系统版本信息 os_version = platform.platform() # 获取安装的安全软件列表 security_software = [] try: process = subprocess.Popen(['wmic', 'product', 'get', 'name'], stdout=subprocess.PIPE) output, error = process.communicate() for line in output.splitlines(): if line.strip() and not line.startswith(b'Name'): security_software.append(line.strip().decode('utf-8')) except Exception as e: print("Error: ", e) # 获取本机IP地址 ip_address = '' try: process = subprocess.Popen(['ipconfig'], stdout=subprocess.PIPE) output, error = process.communicate() for line in output.splitlines(): if b'IPv4 Address' in line: ip_address = line.strip().split(b':')[-1].strip().decode('utf-8') break except Exception as e: print("Error: ", e) # 打印结果 print("操作系统版本:", os_version) print("安全软件列表:", security_software) print("IP地址:", ip_address) ``` 这个脚本使用了platform和subprocess模块来获取系统版本和安全软件列表,以及使用ipconfig命令获取本机IP地址。
收藏(0)  分享
相关标签: 智能问答
问题没解决?让AI助手帮你作答 AI助手
0个回复
  • 消灭零回复