在python中获取当前系统序列号

she*_*tal 2 python

我正在寻找一种使用 python 获取系统序列号的方法。

以下是使用命令提示符获取序列号的命令:

wmic bios get serialnumber
Run Code Online (Sandbox Code Playgroud)

有没有Python库可以得到同样的结果?

pin*_*ulf 7

是的,您可以通过子进程运行 shell 命令

import subprocess
subprocess.check_output('wmic bios get serialnumber').decode("utf-8") 
Run Code Online (Sandbox Code Playgroud)

你应该得到类似的东西

序列号 \r\r\n< 集中 > \r\r\n\r\r\n'

有关更多信息,请参阅此答案