用法:
sys.platform例如,此字符串包含一個平台標識符,可用於將特定於平台的組件附加到
sys.path。對於 Unix 係統(Linux 和 AIX 除外),這是由
uname -s返回的小寫操作係統名稱,並附加了由uname -r返回的版本的第一部分,例如'sunos5'或'freebsd8',at the time when Python was built。除非您想測試特定的係統版本,否則建議使用以下成語:if sys.platform.startswith('freebsd'): # FreeBSD-specific code here... elif sys.platform.startswith('linux'): # Linux-specific code here... elif sys.platform.startswith('aix'): # AIX-specific code here...對於其他係統,這些值為:
係統
platform值AIX
'aix'Linux
'linux'Windows
'win32'Windows/Cygwin
'cygwin'macOS
'darwin'在 3.3 版中更改:在 Linux 上,sys.platform不再包含主要版本。它總是
'linux', 代替'linux2'或者'linux3'.由於較舊的 Python 版本包含版本號,因此建議始終使用startswith上麵介紹的成語。在 3.8 版中更改:在 AIX 上,sys.platform不再包含主要版本。它總是
'aix', 代替'aix5'或者'aix7'.由於較舊的 Python 版本包含版本號,因此建議始終使用startswith上麵介紹的成語。
相關用法
- Python sys.path用法及代碼示例
- Python sys.maxint用法及代碼示例
- Python sys.maxsize()用法及代碼示例
- Python sys.displayhook用法及代碼示例
- Python sys.float_info用法及代碼示例
- Python sys.settrace()用法及代碼示例
- Python sys.setrecursionlimit()用法及代碼示例
- Python sys.getswitchinterval()用法及代碼示例
- Python sys.stdout.write用法及代碼示例
- Python sys.hexversion用法及代碼示例
- Python sys.setswitchinterval()用法及代碼示例
- Python sys.getallocatedblocks()用法及代碼示例
- Python sys.getrecursionlimit()用法及代碼示例
- Python sys.getdefaultencoding()用法及代碼示例
- Python sys._xoptions用法及代碼示例
- Python sympy.rf()用法及代碼示例
- Python sympy.stats.GammaInverse()用法及代碼示例
- Python sympy.integrals.transforms.mellin_transform()用法及代碼示例
- Python sympy.replace()用法及代碼示例
- Python sympy from_rgs()用法及代碼示例
注:本文由純淨天空篩選整理自python.org大神的英文原創作品 sys.platform。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
