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 版本


基础教程推荐
- Kivy 使用 opencv.调整图像大小 2022-01-01
- 究竟什么是“容器"?在蟒蛇?(以及所有的 python 容器类型是什么?) 2022-01-01
- Python 中是否有任何支持将长字符串转储为块文字或折叠块的 yaml 库? 2022-01-01
- 在 Python 中将货币解析为数字 2022-01-01
- 在 Django Admin 中使用内联 OneToOneField 2022-01-01
- matplotlib 设置 yaxis 标签大小 2022-01-01
- 比较两个文本文件以找出差异并将它们输出到新的文本文件 2022-01-01
- kivy 应用程序中的一个简单网页作为小部件 2022-01-01
- Python,确定字符串是否应转换为 Int 或 Float 2022-01-01
- 对多索引数据帧的列进行排序 2022-01-01