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 版本
基础教程推荐
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
- 求两个直方图的卷积 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- 包装空间模型 2022-01-01
