質問

可能な重複:
Python:どのようなOSに対応am I走行すか?

タイトルどうかにすることができますので現在のオペレーティングシステムにpython?

役に立ちましたか?

解決

普段の使用 sys.platform を取得しました。 sys.platform の区別をつけlinux、その他のunixes、OS Xを os.name は"posix"全員について記入してください。

のためのより詳細な情報をご利用 platformモジュール.これはクロスプラットフォーム機能するには、マシンアーキテクチャ、OS、OSのバージョン、Pythonのバージョンなど。またos特有の機能にどの特定のlinuxの配布する

他のヒント

したい場合はユーザーの可読データにも詳しい利用でき 台。プラットフォーム()

>>> import platform
>>> platform.platform()
'Linux-3.3.0-8.fc16.x86_64-x86_64-with-fedora-16-Verne'

platform また、いくつかの有用な方法

>>> platform.system()
'Windows'
>>> platform.release()
'XP'
>>> platform.version()
'5.1.2600'

こちらは少し異なる可能通話ができるだ

import platform
import sys

def linux_distribution():
  try:
    return platform.linux_distribution()
  except:
    return "N/A"

print("""Python version: %s
dist: %s
linux_distribution: %s
system: %s
machine: %s
platform: %s
uname: %s
version: %s
mac_ver: %s
""" % (
sys.version.split('\n'),
str(platform.dist()),
linux_distribution(),
platform.system(),
platform.machine(),
platform.platform(),
platform.uname(),
platform.version(),
platform.mac_ver(),
))

アウトプットのスクリプト実行したくつかの異なるシステム(Linux、Windows、Solaris、MacOS)とアーキテクチャ(x86、x64-適した抜群の高性電pc、sparc)で見ることができます: https://github.com/hpcugent/easybuild/wiki/OS_flavor_name_version

import os
print os.name

これにより、必要な情報まで、通常必要です。の違い、版Windowsを使プラットフォーム固有の方法です。

https://docs.python.org/library/os.html

を補完するグレッグのいいposixシステムは、MacOS、Linux、Unixなど。利用できます。uname()は良い感じのためにどのようなシステムです。

う、日:

import os
if (os.name == "posix"):
    print os.system("uname -a")
# insert other possible OSes here
# ...
else:
    print "unknown OS"
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top