如何识别 Python 在哪个操作系统上运行?
>>> import os >>> os.name 'posix' >>> import platform >>> platform.system() 'Linux' >>> platform.release() '2.6.22-15-generic'
输出platform.system()如下:
platform.system()
Linux
Darwin
Windows
See: platform — Access to underlying platform’s identifying data
platform