How to detect Mac OS version using Python?

后端 未结 5 651
醉梦人生
醉梦人生 2020-12-28 15:56

My application is assumed to be running on a Mac OS X system. However, what I need to do is figure out what version of Mac OS (or Darwin) it is running on, preferably as a

5条回答
  •  天命终不由人
    2020-12-28 16:33

    If you want to run a command - like 'uname' - and get the results as a string, use the subprocess module.

    import subprocess
    output = subprocess.Popen(["uname", "-r"], stdout=subprocess.PIPE).communicate()[0]
    

提交回复
热议问题