当我在控制台 (CMD) 中键入“winver”时,我将获得我的 Windows 版本(内部版本号左侧的四个数字,例如:1803,1903,1909,2004,20H2) 但是我怎样才能在 python 中获得我的 Windows 版本? 我已经试过了:
import os
os.system("winver")
input()
但随后它会像在 cmd 中一样打开一个新窗口,但我只想打印 winver 而没有其他内容,因此我这样做了:
import os
os.system("Reg Query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ReleaseId")
input()
但这里的问题是字符串在字符串中。 “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion”
我该如何解决?请帮忙!
最佳答案
您可以使用 platform模块
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
https://stackoverflow.com/questions/66554824/
相关文章:
javascript - typescript :为什么我们不能为泛型类型分配默认值?
python - 如何在 Python 中将月份名称生成为列表?
c++ - 如果 new 运算符失败,是否可以将指针设置为 null?
flutter - 为什么我们应该在 dart 中使用 static 关键字代替抽象?
github - 如何在两个句子之间添加 Git Readme 中的 Tab 空格?
postgresql - 我想用 mikro-orm 插入,但它找不到我的表 :c (TableNo