我在运行什么操作系统?

2024-04-20 00:52:06 发布

您现在位置:Python中文网/ 问答频道 /正文


Tags: python
3条回答

当当——lbrandy击败了我,但这并不意味着我不能为你提供Vista的系统结果!

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

…我真不敢相信还没有人在Windows10上发布过:

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

下面是Mac上的结果:

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

^{}的输出如下:

  • Linux系统:Linux
  • Mac:Darwin
  • 窗口:Windows

见:^{} — Access to underlying platform’s identifying data

相关问题 更多 >