在Python中可靠地检测Windows [英] Reliably detect Windows in Python

查看:112
本文介绍了在Python中可靠地检测Windows的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用几个Linux工具,因此需要防止在Windows上进行安装,因为它依赖FHS,因此在该平台上变得无用. platform.platform函数接近但仅返回一个字符串.

I'm working on a couple of Linux tools and need to prevent installation on Windows, since it depends on FHS and is thus rendered useless on that platform. The platform.platform function comes close but only returns a string.

不幸的是,我不知道在该字符串中搜索什么才能产生可​​靠的结果.有人知道我要搜索的内容吗,或者有人知道我在这里缺少的另一个功能吗?

Unfortunately I don't know what to search for in that string for it to yield a reliable result. Does anyone know what to search for or does anyone know of another function that I'm missing here?

推荐答案

>>> import platform
>>> platform.system()
'Windows'

这篇关于在Python中可靠地检测Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆