Python: What OS am I running on?

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

    I am using the WLST tool that comes with weblogic, and it doesn't implement the platform package.

    wls:/offline> import os
    wls:/offline> print os.name
    java 
    wls:/offline> import sys
    wls:/offline> print sys.platform
    'java1.5.0_11'
    

    Apart from patching the system javaos.py (issue with os.system() on windows 2003 with jdk1.5) (which I can't do, I have to use weblogic out of the box), this is what I use:

    def iswindows():
      os = java.lang.System.getProperty( "os.name" )
      return "win" in os.lower()
    

提交回复
热议问题