Get Windows Version in Python(在 Python 中获取 Windows 版本)
问题描述
当我输入控制台(CMD)winver"时我将获得我的 Windows 版本(内部版本号左侧的四个数字,例如:1803,1903,1909,2004,20H2)但是我怎样才能在 python 中获得我的 Windows 版本呢?我已经试过了:
when i type into the Console(CMD) "winver" i will get my windows version (The four numbers left of the build number, example: 1803,1903,1909,2004,20H2) But how can i get my windows version in python? i already tried:
import os
os.system("winver")
input()
但是它会像在 cmd 中一样打开一个新窗口,但我只想打印 winver 而不打印其余部分,因此我这样做了:
But then it will open a new window like in the cmd, but i just want to print the winver without the rest, therefore i did this:
import os
os.system("Reg Query "HKLMSOFTWAREMicrosoftWindows NTCurrentVersion" /v ReleaseId")
input()
但这里的问题是字符串在字符串中.HKLMSOFTWAREMicrosoftWindows NTCurrentVersion"
我该如何解决这个问题?请帮忙!
How can i fix that? Please help!
推荐答案
你可以使用 平台模块
you can use platform module
import platform
print(platform.platform())
print(platform.system())
print(platform.release())
print(platform.version())
print(platform.version().split('.')[2])
print(platform.machine())
输出:
Windows-10-10.0.19041-SP0
Windows
10
10.0.19041
19041
AMD64
这篇关于在 Python 中获取 Windows 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Python 中获取 Windows 版本


基础教程推荐
- 使用Python匹配Stata加权xtil命令的确定方法? 2022-01-01
- 如何在 Python 中检测文件是否为二进制(非文本)文 2022-01-01
- 如何在Python中绘制多元函数? 2022-01-01
- 哪些 Python 包提供独立的事件系统? 2022-01-01
- 合并具有多索引的两个数据帧 2022-01-01
- 使 Python 脚本在 Windows 上运行而不指定“.py";延期 2022-01-01
- 将 YAML 文件转换为 python dict 2022-01-01
- 使用 Google App Engine (Python) 将文件上传到 Google Cloud Storage 2022-01-01
- 症状类型错误:无法确定关系的真值 2022-01-01
- Python 的 List 是如何实现的? 2022-01-01