用法:
platform.freedesktop_os_release()從
os-release文件中獲取操作係統標識並將其作為字典返回。os-release文件是 freedesktop.org standard 並且在大多數 Linux 發行版中都可用。一個明顯的例外是 Android 和基於 Android 的發行版。當無法讀取
/etc/os-release和/usr/lib/os-release時,引發OSError或子類。成功時,該函數返回一個字典,其中鍵和值都是字符串。值有它們的特殊字符,如
"和$未加引號。字段NAME,ID和PRETTY_NAME始終根據標準定義。所有其他字段都是可選的。供應商可能包括其他字段。請注意,
NAME,VERSION和VARIANT等字段是適合向用戶展示的字符串。程序應使用ID,ID_LIKE,VERSION_ID或VARIANT_ID等字段來識別 Linux 發行版。例子:
def get_like_distro(): info = platform.freedesktop_os_release() ids = [info["ID"]] if "ID_LIKE" in info: # ids are space separated and ordered by precedence ids.extend(info["ID_LIKE"].split()) return ids3.10 版中的新函數。
相關用法
- Python Tkinter place()用法及代碼示例
- Python plotly.figure_factory.create_annotated_heatmap()用法及代碼示例
- Python plotly.figure_factory.create_choropleth()用法及代碼示例
- Python plotly.express.line()用法及代碼示例
- Python plotly.figure_factory.create_dendrogram()用法及代碼示例
- Python plotly.figure_factory.create_2d_density()用法及代碼示例
- Python plotly.express.scatter_ternary()用法及代碼示例
- Python plotly.figure_factory.create_bullet()用法及代碼示例
- Python plotly.express.line_3d()用法及代碼示例
- Python plotly.express.scatter_geo()用法及代碼示例
- Python plotly.express.scatter_polar()用法及代碼示例
- Python plotly.express.line_ternary()用法及代碼示例
- Python plotly.express.scatter_3d()用法及代碼示例
- Python plotly.express.scatter()用法及代碼示例
- Python plotly.figure_factory.create_candlestick()用法及代碼示例
- Python pandas.arrays.IntervalArray.is_empty用法及代碼示例
- Python pyspark.pandas.Series.dropna用法及代碼示例
- Python pyspark.pandas.groupby.SeriesGroupBy.unique用法及代碼示例
- Python pandas.DataFrame.ewm用法及代碼示例
- Python pandas.api.types.is_timedelta64_ns_dtype用法及代碼示例
注:本文由純淨天空篩選整理自python.org大神的英文原創作品 platform.freedesktop_os_release。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
