Python: What OS am I running on?

前端 未结 26 1565
野趣味
野趣味 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:10

    Dang -- lbrandy beat me to the punch, but that doesn't mean I can't provide you with the system results for Vista!

    >>> import os
    >>> os.name
    'nt'
    >>> import platform
    >>> platform.system()
    'Windows'
    >>> platform.release()
    'Vista'
    

    ...and I can’t believe no one’s posted one for Windows 10 yet:

    >>> import os
    >>> os.name
    'nt'
    >>> import platform
    >>> platform.system()
    'Windows'
    >>> platform.release()
    '10'
    

提交回复
热议问题