Why when use sys.platform on Mac os it print “darwin”?

前端 未结 2 1391
猫巷女王i
猫巷女王i 2021-01-01 15:13

In Python, when I type sys.platform on the Mac OS X the output is \"darwin\"? Why is this so?

相关标签:
2条回答
  • 2021-01-01 15:36

    To expand on the other answers: Darwin is the part of OS X that is the actual operating system, in a stricter sense of that term.

    To give an analogy, Darwin would be the equivalent of Linux - or Linux and the GNU utilities - while Mac OS X would be the equivalent of Ubuntu or another distribution. I.e. a kernel, the basic userspace utilities, and a GUI layer and a bunch of "built-in" applications.

    0 讨论(0)
  • 2021-01-01 15:44

    Because the core of Mac OS X is the Darwin OS.

    Quoting from the linked WikiPedia page:

    Darwin forms the core set of components upon which Mac OS X and iOS are based.

    Even the OS X platform itself reports itself as "Darwin" when you ask it:

    $ uname
    Darwin
    

    Python merely uses that same platform identifier.

    0 讨论(0)
提交回复
热议问题