Python: What OS am I running on?

前端 未结 26 2084
野趣味
野趣味 2020-11-22 05:44

What do I need to look at to see whether I\'m on Windows or Unix, etc?

26条回答
  •  故里飘歌
    2020-11-22 06:15

    >>> import os
    >>> os.name
    'posix'
    >>> import platform
    >>> platform.system()
    'Linux'
    >>> platform.release()
    '2.6.22-15-generic'
    

    The output of platform.system() is as follows:

    • Linux: Linux
    • Mac: Darwin
    • Windows: Windows

    See: platform — Access to underlying platform’s identifying data

提交回复
热议问题