IT/python

[python] os 종류 확인하기

심량 2020. 8. 11. 09:35

실행 환경

  • Windows 10 python 3.8.3
  • openwrt 18.06 python 3.8.3
  • ubuntu 20.04 python 3.8.2


os 별 실행 결과

  • os.name
    • import os
      print(os.name)
    • Windows 10
      • nt
    • openwrt 18.06, ubuntu 20.04
      • posix
  • sys.platform
    • import sys
      print(sys.platform)
    • Windows 10
      • win32
    • openwrt 18.06, ubuntu 20.04
      • linux
  • platform.system()
    • import platform
      print(platform.system())
    • Windows 10
      • Windows
    • openwrt 18.06, ubuntu 20.04
      • Linux
  • platform.uname()
    • import platform
      print(platform.uname())
      print(platform.uname().system())
    • Windows 10
      • uname_result(system='Windows', node='DESKTOP-2N7390S', release='10', version='10.0.17763', machine='AMD64', processor='Intel64 Family 6 Model 158 Stepping 9, GenuineIntel')
        Windows
    • openwrt 18.06
      • uname_result(system='Linux', node='wizfi630s', release='4.14.111', version='#0 Tue Apr 9 20:25:11 2019', machine='mips', processor='')
        Linux
    • ubuntu 20.04
      • uname_result(system='Linux', node='sr-u20-vb', release=5.4.0-42-generic', version='#46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020', machine='x86_64', processor='x86_64')
        Linux