qiuyouzhi 发表于 2020-3-21 12:58:55

Python 获取当前操作系统

Python 获取当前操作系统

使用sys模块:

>>> import sys
>>> sys.platform
'win32'

于是,可以写出如下代码:

import sys
useros = sys.platform
class SystemError(BaseException):
    pass
if 'win32' in useros:
    raise SystemError("操作系统不对!请使用Mac/Linux系统!")

用Windows的小伙伴试试~
页: [1]
查看完整版本: Python 获取当前操作系统