Python 导入平台获取操作系统信息
如何创建python脚本以获取这些字段的服务器信息库Python 导入平台获取操作系统信息,python,server,Python,Server,如何创建python脚本以获取这些字段的服务器信息库 hostname, osrelease, if it's a virtual or physical server. 输出 hostname1, redhat 5.8, VMware 我有这样的想法: import platform print 'uname:', platform.uname() print 'system :', platform.system() print 'node :', platform.no
hostname, osrelease, if it's a virtual or physical server.
输出
hostname1, redhat 5.8, VMware
我有这样的想法:
import platform
print 'uname:', platform.uname()
print 'system :', platform.system()
print 'node :', platform.node()
print 'release :', platform.release()
所需输出的前两列非常容易获得:
import platform
print (platform.node(), ' '.join(platform.dist()[:2]))
最后一列的信息,即Python是否在虚拟机或物理机下运行,似乎很棘手。有关一些提示,请参阅以下页面: