473 lines
34 KiB
HTML
473 lines
34 KiB
HTML
|
||
<!DOCTYPE html>
|
||
|
||
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh_CN">
|
||
<head>
|
||
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
|
||
|
||
<title>platform --- 获取底层平台的标识数据 — Python 3.8.20 文档</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
||
<link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
|
||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||
|
||
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
||
<script src="../_static/jquery.js"></script>
|
||
<script src="../_static/underscore.js"></script>
|
||
<script src="../_static/doctools.js"></script>
|
||
<script src="../_static/language_data.js"></script>
|
||
<script src="../_static/translations.js"></script>
|
||
|
||
<script src="../_static/sidebar.js"></script>
|
||
|
||
<link rel="search" type="application/opensearchdescription+xml"
|
||
title="在 Python 3.8.20 文档 中搜索"
|
||
href="../_static/opensearch.xml"/>
|
||
<link rel="author" title="关于这些文档" href="../about.html" />
|
||
<link rel="index" title="索引" href="../genindex.html" />
|
||
<link rel="search" title="搜索" href="../search.html" />
|
||
<link rel="copyright" title="版权所有" href="../copyright.html" />
|
||
<link rel="next" title="errno --- 标准 errno 系统符号" href="errno.html" />
|
||
<link rel="prev" title="curses.panel --- curses 的 panel 栈扩展" href="curses.panel.html" />
|
||
<link rel="canonical" href="https://docs.python.org/3/library/platform.html" />
|
||
|
||
|
||
|
||
|
||
|
||
<style>
|
||
@media only screen {
|
||
table.full-width-table {
|
||
width: 100%;
|
||
}
|
||
}
|
||
</style>
|
||
<link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
|
||
<script type="text/javascript" src="../_static/copybutton.js"></script>
|
||
<script type="text/javascript" src="../_static/menu.js"></script>
|
||
|
||
</head>
|
||
<body>
|
||
<div class="mobile-nav">
|
||
<input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
|
||
aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
|
||
<label for="menuToggler" class="toggler__label">
|
||
<span></span>
|
||
</label>
|
||
<nav class="nav-content" role="navigation">
|
||
<a href="https://www.python.org/" class="nav-logo">
|
||
<img src="../_static/py.svg" alt="Logo"/>
|
||
</a>
|
||
<div class="version_switcher_placeholder"></div>
|
||
<form role="search" class="search" action="../search.html" method="get">
|
||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
|
||
<path fill-rule="nonzero"
|
||
d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" fill="#444"></path>
|
||
</svg>
|
||
<input type="text" name="q" aria-label="快速搜索"/>
|
||
<input type="submit" value="转向"/>
|
||
</form>
|
||
</nav>
|
||
<div class="menu-wrapper">
|
||
<nav class="menu" role="navigation" aria-label="main navigation">
|
||
<div class="language_switcher_placeholder"></div>
|
||
<h3><a href="../contents.html">目录</a></h3>
|
||
<ul>
|
||
<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">platform</span></code> --- 获取底层平台的标识数据</a><ul>
|
||
<li><a class="reference internal" href="#cross-platform">跨平台</a></li>
|
||
<li><a class="reference internal" href="#java-platform">Java平台</a></li>
|
||
<li><a class="reference internal" href="#windows-platform">Windows平台</a></li>
|
||
<li><a class="reference internal" href="#mac-os-platform">Mac OS平台</a></li>
|
||
<li><a class="reference internal" href="#unix-platforms">Unix 平台</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
<h4>上一个主题</h4>
|
||
<p class="topless"><a href="curses.panel.html"
|
||
title="上一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">curses.panel</span></code> --- curses 的 panel 栈扩展</a></p>
|
||
<h4>下一个主题</h4>
|
||
<p class="topless"><a href="errno.html"
|
||
title="下一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">errno</span></code> --- 标准 errno 系统符号</a></p>
|
||
<div role="note" aria-label="source link">
|
||
<h3>本页</h3>
|
||
<ul class="this-page-menu">
|
||
<li><a href="../bugs.html">报告 Bug</a></li>
|
||
<li>
|
||
<a href="https://github.com/python/cpython/blob/3.8/Doc/library/platform.rst"
|
||
rel="nofollow">显示源代码
|
||
</a>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</nav>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outdated-warning" style="padding: .5em; text-align: center; background-color: #FFBABA; color: #6A0E0E;">
|
||
这个文档所针对的是一个已不再受支持的 Python 旧版本。
|
||
你应当升级版本,并阅读
|
||
<a href="/3/library/platform.html"> Python 当前稳定版本的文档</a>.
|
||
</div>
|
||
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>导航</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="总目录"
|
||
accesskey="I">索引</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python 模块索引"
|
||
>模块</a> |</li>
|
||
<li class="right" >
|
||
<a href="errno.html" title="errno --- 标准 errno 系统符号"
|
||
accesskey="N">下一页</a> |</li>
|
||
<li class="right" >
|
||
<a href="curses.panel.html" title="curses.panel --- curses 的 panel 栈扩展"
|
||
accesskey="P">上一页</a> |</li>
|
||
|
||
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
|
||
<li><a href="https://www.python.org/">Python</a> »</li>
|
||
<li class="switchers">
|
||
<div class="language_switcher_placeholder"></div>
|
||
<div class="version_switcher_placeholder"></div>
|
||
</li>
|
||
<li>
|
||
|
||
</li>
|
||
<li id="cpython-language-and-version">
|
||
<a href="../index.html">3.8.20 Documentation</a> »
|
||
</li>
|
||
|
||
<li class="nav-item nav-item-1"><a href="index.html" >Python 标准库</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="allos.html" accesskey="U">通用操作系统服务</a> »</li>
|
||
<li class="right">
|
||
|
||
|
||
<div class="inline-search" role="search">
|
||
<form class="inline-search" action="../search.html" method="get">
|
||
<input placeholder="快速搜索" aria-label="快速搜索" type="text" name="q" />
|
||
<input type="submit" value="转向" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
</div>
|
||
|
|
||
</li>
|
||
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="document">
|
||
<div class="documentwrapper">
|
||
<div class="bodywrapper">
|
||
<div class="body" role="main">
|
||
|
||
<section id="module-platform">
|
||
<span id="platform-access-to-underlying-platform-s-identifying-data"></span><h1><a class="reference internal" href="#module-platform" title="platform: Retrieves as much platform identifying data as possible."><code class="xref py py-mod docutils literal notranslate"><span class="pre">platform</span></code></a> --- 获取底层平台的标识数据<a class="headerlink" href="#module-platform" title="永久链接至标题">¶</a></h1>
|
||
<p><strong>示例代码:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.8/Lib/platform.py">Lib/platform.py</a></p>
|
||
<hr class="docutils" />
|
||
<div class="admonition note">
|
||
<p class="admonition-title">注解</p>
|
||
<p>特定平台按字母顺序排列,Linux 包括在 Unix 小节之中。</p>
|
||
</div>
|
||
<section id="cross-platform">
|
||
<h2>跨平台<a class="headerlink" href="#cross-platform" title="永久链接至标题">¶</a></h2>
|
||
<dl class="function">
|
||
<dt id="platform.architecture">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">architecture</code><span class="sig-paren">(</span><em class="sig-param">executable=sys.executable</em>, <em class="sig-param">bits=''</em>, <em class="sig-param">linkage=''</em><span class="sig-paren">)</span><a class="headerlink" href="#platform.architecture" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>查询给定的可执行文件(默认为 Python 解释器二进制码文件)来获取各种架构信息。</p>
|
||
<p>返回一个元素 <code class="docutils literal notranslate"><span class="pre">(bits,</span> <span class="pre">linkage)</span></code>,其中包含可执行文件所使用的位架构和链接格式信息。 这两个值均以字符串形式返回。</p>
|
||
<p>无法确定的值将返回为形参预设所给出的值。 如果给出的位数为 <code class="docutils literal notranslate"><span class="pre">''</span></code>,则会使用 <code class="docutils literal notranslate"><span class="pre">sizeof(pointer)</span></code> (或者当 Python 版本 < 1.5.2 时为 <code class="docutils literal notranslate"><span class="pre">sizeof(long)</span></code>) 作为所支持的指针大小的提示。</p>
|
||
<p>此函数依赖于系统的 <code class="file docutils literal notranslate"><span class="pre">file</span></code> 命令来执行实际的操作。 这在几乎所有 Unix 平台和某些非 Unix 平台上只有当可执行文件指向 Python 解释器时才可用。 当以上要求不满足时将会使用合理的默认值。</p>
|
||
<div class="admonition note">
|
||
<p class="admonition-title">注解</p>
|
||
<p>在 Mac OS X(也许还有其他平台)上,可执行文件可能是包含多种架构的通用文件。</p>
|
||
<p>要获取当前解释器的“64 位性”,更可靠的做法是查询 <a class="reference internal" href="sys.html#sys.maxsize" title="sys.maxsize"><code class="xref py py-attr docutils literal notranslate"><span class="pre">sys.maxsize</span></code></a> 属性:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">is_64bits</span> <span class="o">=</span> <span class="n">sys</span><span class="o">.</span><span class="n">maxsize</span> <span class="o">></span> <span class="mi">2</span><span class="o">**</span><span class="mi">32</span>
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="platform.machine">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">machine</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#platform.machine" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回机器类型,例如 <code class="docutils literal notranslate"><span class="pre">'i386'</span></code>。 如果该值无法确定则会返回一个空字符串。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="platform.node">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">node</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#platform.node" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回计算机的网络名称(可能不是完整限定名称!)。 如果该值无法确定则会返回一个空字符串。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="platform.platform">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">platform</code><span class="sig-paren">(</span><em class="sig-param">aliased=0</em>, <em class="sig-param">terse=0</em><span class="sig-paren">)</span><a class="headerlink" href="#platform.platform" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回一个标识底层平台的字符串,其中带有尽可能多的有用信息。</p>
|
||
<p>输出信息的目标是“人类易读”而非机器易解析。 它在不同平台上可能看起来不一致,这是有意为之的。</p>
|
||
<p>如果 <em>aliased</em> 为真值,此函数将使用各种平台不同与其通常名称的别名来报告系统名称,例如 SunOS 将被报告为 Solaris。 <a class="reference internal" href="#platform.system_alias" title="platform.system_alias"><code class="xref py py-func docutils literal notranslate"><span class="pre">system_alias()</span></code></a> 函数将被用于实现此功能。</p>
|
||
<p>将 <em>terse</em> 设为真值将导致此函数只返回标识平台所必须的最小量信息。</p>
|
||
<div class="versionchanged">
|
||
<p><span class="versionmodified changed">在 3.8 版更改: </span>在 macOS 上,此函数现在会在 <a class="reference internal" href="#platform.mac_ver" title="platform.mac_ver"><code class="xref py py-func docutils literal notranslate"><span class="pre">mac_ver()</span></code></a> 返回的发布版字符串非空时使用它,以便获取 macOS 版本而非 darwin 版本。</p>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="platform.processor">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">processor</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#platform.processor" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回(真实的)处理器名称,例如 <code class="docutils literal notranslate"><span class="pre">'amdk6'</span></code>。</p>
|
||
<p>如果该值无法确定则将返回空字符串。 请注意许多平台都不提供此信息或是简单地返回与 <a class="reference internal" href="#platform.machine" title="platform.machine"><code class="xref py py-func docutils literal notranslate"><span class="pre">machine()</span></code></a> 相同的值。 NetBSD 则会提供此信息。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="platform.python_build">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">python_build</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#platform.python_build" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回一个元组 <code class="docutils literal notranslate"><span class="pre">(buildno,</span> <span class="pre">builddate)</span></code>,以字符串表示的 Python 编译代码和日期。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="platform.python_compiler">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">python_compiler</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#platform.python_compiler" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回一个表示用于编译 Python 的编译器的的字符串。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="platform.python_branch">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">python_branch</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#platform.python_branch" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回一个表示 Python 实现的 SCM 分支的字符串。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="platform.python_implementation">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">python_implementation</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#platform.python_implementation" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回一个标识 Python 实现的字符串。 可能的返回值有: 'CPython', 'IronPython', 'Jython', 'PyPy'。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="platform.python_revision">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">python_revision</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#platform.python_revision" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回一个标识 Python 实现的 SCM 修订版的字符串。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="platform.python_version">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">python_version</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#platform.python_version" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>将 Python 版本以字符串 <code class="docutils literal notranslate"><span class="pre">'major.minor.patchlevel'</span></code> 形式返回。</p>
|
||
<p>请注意此返回值不同于 Python <code class="docutils literal notranslate"><span class="pre">sys.version</span></code>,它将总是包括 patchlevel (默认为 0)。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="platform.python_version_tuple">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">python_version_tuple</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#platform.python_version_tuple" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>将 Python 版本以字符串元组 <code class="docutils literal notranslate"><span class="pre">(major,</span> <span class="pre">minor,</span> <span class="pre">patchlevel)</span></code> 形式返回。</p>
|
||
<p>请注意此返回值不同于 Python <code class="docutils literal notranslate"><span class="pre">sys.version</span></code>,它将总是包括 patchlevel (默认为 <code class="docutils literal notranslate"><span class="pre">'0'</span></code>)。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="platform.release">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">release</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#platform.release" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回系统的发布版本,例如 <code class="docutils literal notranslate"><span class="pre">'2.2.0'</span></code> 或 <code class="docutils literal notranslate"><span class="pre">'NT'</span></code>,如果该值无法确定则将返回一个空字符串。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="platform.system">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">system</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#platform.system" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回系统平台/OS的名称,例如 <code class="docutils literal notranslate"><span class="pre">'Linux'</span></code>, <code class="docutils literal notranslate"><span class="pre">'Darwin'</span></code>, <code class="docutils literal notranslate"><span class="pre">'Java'</span></code>, <code class="docutils literal notranslate"><span class="pre">'Windows'</span></code>。 如果该值无法确定则将返回一个空字符串。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="platform.system_alias">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">system_alias</code><span class="sig-paren">(</span><em class="sig-param">system</em>, <em class="sig-param">release</em>, <em class="sig-param">version</em><span class="sig-paren">)</span><a class="headerlink" href="#platform.system_alias" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回别名为某些系统所使用的常见营销名称的 <code class="docutils literal notranslate"><span class="pre">(system,</span> <span class="pre">release,</span> <span class="pre">version)</span></code>。 它还会在可能导致混淆的情况下对信息进行一些重排序操作。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="platform.version">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">version</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#platform.version" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回系统的发布版本信息,例如 <code class="docutils literal notranslate"><span class="pre">'#3</span> <span class="pre">on</span> <span class="pre">degas'</span></code>。 如果该值无法确定则将返回一个空字符串。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="platform.uname">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">uname</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#platform.uname" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>具有高可移植性的 uname 接口。 返回包含六个属性的 <a class="reference internal" href="collections.html#collections.namedtuple" title="collections.namedtuple"><code class="xref py py-func docutils literal notranslate"><span class="pre">namedtuple()</span></code></a>: <a class="reference internal" href="#platform.system" title="platform.system"><code class="xref py py-attr docutils literal notranslate"><span class="pre">system</span></code></a>, <a class="reference internal" href="#platform.node" title="platform.node"><code class="xref py py-attr docutils literal notranslate"><span class="pre">node</span></code></a>, <a class="reference internal" href="#platform.release" title="platform.release"><code class="xref py py-attr docutils literal notranslate"><span class="pre">release</span></code></a>, <a class="reference internal" href="#platform.version" title="platform.version"><code class="xref py py-attr docutils literal notranslate"><span class="pre">version</span></code></a>, <a class="reference internal" href="#platform.machine" title="platform.machine"><code class="xref py py-attr docutils literal notranslate"><span class="pre">machine</span></code></a> 和 <a class="reference internal" href="#platform.processor" title="platform.processor"><code class="xref py py-attr docutils literal notranslate"><span class="pre">processor</span></code></a>。</p>
|
||
<p>请注意此函数添加的第六个属性 (<a class="reference internal" href="#platform.processor" title="platform.processor"><code class="xref py py-attr docutils literal notranslate"><span class="pre">processor</span></code></a>) 并不存在于 <a class="reference internal" href="os.html#os.uname" title="os.uname"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.uname()</span></code></a> 的结果中。 并且前两个属性的属性名称也不一致;<a class="reference internal" href="os.html#os.uname" title="os.uname"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.uname()</span></code></a> 是将它们称为 <code class="xref py py-attr docutils literal notranslate"><span class="pre">sysname</span></code> 和 <code class="xref py py-attr docutils literal notranslate"><span class="pre">nodename</span></code>。</p>
|
||
<p>无法确定的条目会被设为 <code class="docutils literal notranslate"><span class="pre">''</span></code>。</p>
|
||
<div class="versionchanged">
|
||
<p><span class="versionmodified changed">在 3.3 版更改: </span>将结果从元组改为命名元组。</p>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
</section>
|
||
<section id="java-platform">
|
||
<h2>Java平台<a class="headerlink" href="#java-platform" title="永久链接至标题">¶</a></h2>
|
||
<dl class="function">
|
||
<dt id="platform.java_ver">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">java_ver</code><span class="sig-paren">(</span><em class="sig-param">release=''</em>, <em class="sig-param">vendor=''</em>, <em class="sig-param">vminfo=(''</em>, <em class="sig-param">''</em>, <em class="sig-param">'')</em>, <em class="sig-param">osinfo=(''</em>, <em class="sig-param">''</em>, <em class="sig-param">'')</em><span class="sig-paren">)</span><a class="headerlink" href="#platform.java_ver" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>Jython的版本接口</p>
|
||
<p>返回一个元组 <code class="docutils literal notranslate"><span class="pre">(release,</span> <span class="pre">vendor,</span> <span class="pre">vminfo,</span> <span class="pre">osinfo)</span></code>,其中 <em>vminfo</em> 为元组 <code class="docutils literal notranslate"><span class="pre">(vm_name,</span> <span class="pre">vm_release,</span> <span class="pre">vm_vendor)</span></code> 而 <em>osinfo</em> 为元组 <code class="docutils literal notranslate"><span class="pre">(os_name,</span> <span class="pre">os_version,</span> <span class="pre">os_arch)</span></code>。 无法确定的值将设为由形参所给出的默认值 (默认均为 <code class="docutils literal notranslate"><span class="pre">''</span></code>)。</p>
|
||
</dd></dl>
|
||
|
||
</section>
|
||
<section id="windows-platform">
|
||
<h2>Windows平台<a class="headerlink" href="#windows-platform" title="永久链接至标题">¶</a></h2>
|
||
<dl class="function">
|
||
<dt id="platform.win32_ver">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">win32_ver</code><span class="sig-paren">(</span><em class="sig-param">release=''</em>, <em class="sig-param">version=''</em>, <em class="sig-param">csd=''</em>, <em class="sig-param">ptype=''</em><span class="sig-paren">)</span><a class="headerlink" href="#platform.win32_ver" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>从 Windows 注册表获取额外的版本信息并返回一个元组 <code class="docutils literal notranslate"><span class="pre">(release,</span> <span class="pre">version,</span> <span class="pre">csd,</span> <span class="pre">ptype)</span></code> 表示 OS 发行版, 版本号, CSD 级别 (Service Pack) 和 OS 类型 (多个/单个处理器)。</p>
|
||
<p>一点提示: <em>ptype</em> 在单个处理器的 NT 机器上为 <code class="docutils literal notranslate"><span class="pre">'Uniprocessor</span> <span class="pre">Free'</span></code> 而在多个处理器的机器上为 <code class="docutils literal notranslate"><span class="pre">'Multiprocessor</span> <span class="pre">Free'</span></code>。 <em>'Free'</em> 是指该 OS 版本没有调试代码。 它还可能显示 <em>'Checked'</em> 表示该 OS 版本使用了调试代码,即检测参数、范围等的代码。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="platform.win32_edition">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">win32_edition</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#platform.win32_edition" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回一个代表当前 Windows 版本的字符串。 可能的值包括但不限于 <code class="docutils literal notranslate"><span class="pre">'Enterprise'</span></code>, <code class="docutils literal notranslate"><span class="pre">'IoTUAP'</span></code>, <code class="docutils literal notranslate"><span class="pre">'ServerStandard'</span></code> 和 <code class="docutils literal notranslate"><span class="pre">'nanoserver'</span></code>。</p>
|
||
<div class="versionadded">
|
||
<p><span class="versionmodified added">3.8 新版功能.</span></p>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="platform.win32_is_iot">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">win32_is_iot</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#platform.win32_is_iot" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>如果 <a class="reference internal" href="#platform.win32_edition" title="platform.win32_edition"><code class="xref py py-func docutils literal notranslate"><span class="pre">win32_edition()</span></code></a> 返回的 Windows 版本被识别为 IoT 版则返回 <code class="docutils literal notranslate"><span class="pre">True</span></code>。</p>
|
||
<div class="versionadded">
|
||
<p><span class="versionmodified added">3.8 新版功能.</span></p>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
</section>
|
||
<section id="mac-os-platform">
|
||
<h2>Mac OS平台<a class="headerlink" href="#mac-os-platform" title="永久链接至标题">¶</a></h2>
|
||
<dl class="function">
|
||
<dt id="platform.mac_ver">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">mac_ver</code><span class="sig-paren">(</span><em class="sig-param">release=''</em>, <em class="sig-param">versioninfo=(''</em>, <em class="sig-param">''</em>, <em class="sig-param">'')</em>, <em class="sig-param">machine=''</em><span class="sig-paren">)</span><a class="headerlink" href="#platform.mac_ver" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>获取 Mac OS 版本信息并将其返回为元组 <code class="docutils literal notranslate"><span class="pre">(release,</span> <span class="pre">versioninfo,</span> <span class="pre">machine)</span></code>,其中 <em>versioninfo</em> 是一个元组 <code class="docutils literal notranslate"><span class="pre">(version,</span> <span class="pre">dev_stage,</span> <span class="pre">non_release_version)</span></code>。</p>
|
||
<p>无法确定的条目会被设为 <code class="docutils literal notranslate"><span class="pre">''</span></code>。 所有元组条目均为字符串。</p>
|
||
</dd></dl>
|
||
|
||
</section>
|
||
<section id="unix-platforms">
|
||
<h2>Unix 平台<a class="headerlink" href="#unix-platforms" title="永久链接至标题">¶</a></h2>
|
||
<dl class="function">
|
||
<dt id="platform.libc_ver">
|
||
<code class="sig-prename descclassname">platform.</code><code class="sig-name descname">libc_ver</code><span class="sig-paren">(</span><em class="sig-param">executable=sys.executable</em>, <em class="sig-param">lib=''</em>, <em class="sig-param">version=''</em>, <em class="sig-param">chunksize=16384</em><span class="sig-paren">)</span><a class="headerlink" href="#platform.libc_ver" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>尝试确定可执行文件(默认为 Python 解释器)所链接到的 libc 版本。 返回一个字符串元组 <code class="docutils literal notranslate"><span class="pre">(lib,</span> <span class="pre">version)</span></code>,当查找失败时其默认值将设为给定的形参值。</p>
|
||
<p>请注意此函数对于不同 libc 版本向可执行文件添加符号的方式有深层的关联,可能仅适用于使用 <strong class="program">gcc</strong> 编译出来的可执行文件。</p>
|
||
<p>文件将按 <em>chunksize</em> 个字节的分块来读取和扫描。</p>
|
||
</dd></dl>
|
||
|
||
</section>
|
||
</section>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||
<div class="sphinxsidebarwrapper">
|
||
<h3><a href="../contents.html">目录</a></h3>
|
||
<ul>
|
||
<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">platform</span></code> --- 获取底层平台的标识数据</a><ul>
|
||
<li><a class="reference internal" href="#cross-platform">跨平台</a></li>
|
||
<li><a class="reference internal" href="#java-platform">Java平台</a></li>
|
||
<li><a class="reference internal" href="#windows-platform">Windows平台</a></li>
|
||
<li><a class="reference internal" href="#mac-os-platform">Mac OS平台</a></li>
|
||
<li><a class="reference internal" href="#unix-platforms">Unix 平台</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
<h4>上一个主题</h4>
|
||
<p class="topless"><a href="curses.panel.html"
|
||
title="上一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">curses.panel</span></code> --- curses 的 panel 栈扩展</a></p>
|
||
<h4>下一个主题</h4>
|
||
<p class="topless"><a href="errno.html"
|
||
title="下一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">errno</span></code> --- 标准 errno 系统符号</a></p>
|
||
<div role="note" aria-label="source link">
|
||
<h3>本页</h3>
|
||
<ul class="this-page-menu">
|
||
<li><a href="../bugs.html">报告 Bug</a></li>
|
||
<li>
|
||
<a href="https://github.com/python/cpython/blob/3.8/Doc/library/platform.rst"
|
||
rel="nofollow">显示源代码
|
||
</a>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="clearer"></div>
|
||
</div>
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>导航</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="总目录"
|
||
>索引</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python 模块索引"
|
||
>模块</a> |</li>
|
||
<li class="right" >
|
||
<a href="errno.html" title="errno --- 标准 errno 系统符号"
|
||
>下一页</a> |</li>
|
||
<li class="right" >
|
||
<a href="curses.panel.html" title="curses.panel --- curses 的 panel 栈扩展"
|
||
>上一页</a> |</li>
|
||
|
||
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
|
||
<li><a href="https://www.python.org/">Python</a> »</li>
|
||
<li class="switchers">
|
||
<div class="language_switcher_placeholder"></div>
|
||
<div class="version_switcher_placeholder"></div>
|
||
</li>
|
||
<li>
|
||
|
||
</li>
|
||
<li id="cpython-language-and-version">
|
||
<a href="../index.html">3.8.20 Documentation</a> »
|
||
</li>
|
||
|
||
<li class="nav-item nav-item-1"><a href="index.html" >Python 标准库</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="allos.html" >通用操作系统服务</a> »</li>
|
||
<li class="right">
|
||
|
||
|
||
<div class="inline-search" role="search">
|
||
<form class="inline-search" action="../search.html" method="get">
|
||
<input placeholder="快速搜索" aria-label="快速搜索" type="text" name="q" />
|
||
<input type="submit" value="转向" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
</div>
|
||
|
|
||
</li>
|
||
|
||
</ul>
|
||
</div>
|
||
<div class="footer">
|
||
© <a href="../copyright.html">版权所有</a> 2001-2024, Python Software Foundation.
|
||
<br />
|
||
This page is licensed under the Python Software Foundation License Version 2.
|
||
<br />
|
||
Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
|
||
<br />
|
||
|
||
<br />
|
||
|
||
The Python Software Foundation is a non-profit corporation.
|
||
<a href="https://www.python.org/psf/donations/">Please donate.</a>
|
||
<br />
|
||
<br />
|
||
|
||
最后更新于 12月 09, 2024.
|
||
<a href="https://docs.python.org/3/bugs.html">Found a bug</a>?
|
||
<br />
|
||
|
||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 2.4.4.
|
||
</div>
|
||
|
||
</body>
|
||
</html> |