当我输入控制台(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模板网!
如何在 Python 中将货币字符串转换为浮点数?How do I convert a currency string to a floating point number in Python?(如何在 Python 中将货币字符串转换为浮点数?)
在 Pandas 中解析多索引 Excel 文件Parsing a Multi-Index Excel File in Pandas(在 Pandas 中解析多索引 Excel 文件)
pandas 时间序列 between_datetime 函数?pandas timeseries between_datetime function?( pandas 时间序列 between_datetime 函数?)
pandas 重新采样到每月的特定工作日pandas resample to specific weekday in month( pandas 重新采样到每月的特定工作日)
Python - 如何标准化时间序列数据Python - how to normalize time-series data(Python - 如何标准化时间序列数据)
statsmodels 使用 ARMA 模型进行预测statsmodels forecasting using ARMA model(statsmodels 使用 ARMA 模型进行预测)