当我输入控制台(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 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!