Vor*_*tty 4 operating-system differentiation python-3.x
我四处寻找我的问题的解决方案,我能找到的最好的是:
from sys import platform
if platform == "linux" or platform == "linux2":
# linux
elif platform == "darwin":
# OS X
elif platform == "win32":
# Windows...
Run Code Online (Sandbox Code Playgroud)
有谁知道我如何将 Linux PC 与 android 区分开来,因为 android 是基于 Linux 的。如果这是可能的,我如何将 Mac OS 与 iOS 区分开来
Ale*_*ine 10
使用platform模块:
import platform
print(platform.system())
print(platform.release())
print(platform.version())
Run Code Online (Sandbox Code Playgroud)
请注意,在 Mac 上运行的系统将返回“达尔文” platform.system()
platform.platform() 将返回非常详细的数据,例如
'Linux-3.3.0-8.fc16.x86_64-x86_64-with-fedora-16-Verne'
Run Code Online (Sandbox Code Playgroud)
小智 5
你可以看到我的 github repo https://github.com/sk3pp3r/PyOS并使用 pyos.py 脚本
import platform
plt = platform.system()
if plt == "Windows":
print("Your system is Windows")
# do x y z
elif plt == "Linux":
print("Your system is Linux")
# do x y z
elif plt == "Darwin":
print("Your system is MacOS")
# do x y z
else:
print("Unidentified system")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7677 次 |
| 最近记录: |