uTools-Manuals/docs/python/binhex.html
2019-04-08 23:22:26 +08:00

1 line
4.4 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div class="body" role="main"><div class="section" id="module-binhex"><h1><span class="yiyi-st" id="yiyi-10">19.7. <a class="reference internal" href="#module-binhex" title="binhex: Encode and decode files in binhex4 format."><code class="xref py py-mod docutils literal"><span class="pre">binhex</span></code></a> - 编码和解码binhex4文件</span></h1><p><span class="yiyi-st" id="yiyi-11"><strong>源代码:</strong> <a class="reference external" href="https://hg.python.org/cpython/file/3.5/Lib/binhex.py">Lib / binhex.py</a></span></p><p><span class="yiyi-st" id="yiyi-12">此模块以binhex4格式编码和解码文件这种格式允许以ASCII格式表示Macintosh文件。</span><span class="yiyi-st" id="yiyi-13">只处理数据fork。</span></p><p><span class="yiyi-st" id="yiyi-14"><a class="reference internal" href="#module-binhex" title="binhex: Encode and decode files in binhex4 format."><code class="xref py py-mod docutils literal"><span class="pre">binhex</span></code></a>模块定义以下函数:</span></p><dl class="function"><dt id="binhex.binhex"><span class="yiyi-st" id="yiyi-15"> <code class="descclassname">binhex.</code><code class="descname">binhex</code><span class="sig-paren">(</span><em>input</em>, <em>output</em><span class="sig-paren">)</span></span></dt><dd><p><span class="yiyi-st" id="yiyi-16">将文件名输入的二进制文件转换为binhex文件输出。 <em></em><em></em></span><span class="yiyi-st" id="yiyi-17"><em>输出</em>参数可以是文件名或类似文件的对象(支持<code class="xref py py-meth docutils literal"><span class="pre">write()</span></code><code class="xref py py-meth docutils literal"><span class="pre">close()</span></code>方法的任何对象)。</span></p></dd></dl><dl class="function"><dt id="binhex.hexbin"><span class="yiyi-st" id="yiyi-18"> <code class="descclassname">binhex.</code><code class="descname">hexbin</code><span class="sig-paren">(</span><em>input</em>, <em>output</em><span class="sig-paren">)</span></span></dt><dd><p><span class="yiyi-st" id="yiyi-19">解码binhex文件<em>输入</em></span><span class="yiyi-st" id="yiyi-20"><em>输入</em>可以是支持<code class="xref py py-meth docutils literal"><span class="pre">read()</span></code><code class="xref py py-meth docutils literal"><span class="pre">close()</span></code>方法的文件名或类似文件的对象。</span><span class="yiyi-st" id="yiyi-21">生成的文件将写入名为<em>输出</em>的文件,除非参数为<code class="docutils literal"><span class="pre">None</span></code>在这种情况下将从binhex文件读取输出文件名。</span></p></dd></dl><p><span class="yiyi-st" id="yiyi-22">还定义了以下异常:</span></p><dl class="exception"><dt id="binhex.Error"><span class="yiyi-st" id="yiyi-23"> <em class="property">exception </em><code class="descclassname">binhex.</code><code class="descname">Error</code></span></dt><dd><p><span class="yiyi-st" id="yiyi-24">当无法使用binhex格式例如文件名太长不适合文件名字段或当输入未正确编码的binhex数据时出现异常。</span></p></dd></dl><div class="admonition seealso"><p class="first admonition-title"><span class="yiyi-st" id="yiyi-25">也可以看看</span></p><dl class="last docutils"><dt><span class="yiyi-st" id="yiyi-26">模块<a class="reference internal" href="binascii.html#module-binascii" title="binascii: Tools for converting between binary and various ASCII-encoded binary representations."><code class="xref py py-mod docutils literal"><span class="pre">binascii</span></code></a></span></dt><dd><span class="yiyi-st" id="yiyi-27">支持模块包含ASCII到二进制和二进制到ASCII转换。</span></dd></dl></div><div class="section" id="notes"><h2><span class="yiyi-st" id="yiyi-28">19.7.1. </span><span class="yiyi-st" id="yiyi-29">备注</span></h2><p><span class="yiyi-st" id="yiyi-30">有一个替代的,更强大的接口到编码器和解码器,请参阅源的详细信息。</span></p><p><span class="yiyi-st" id="yiyi-31">如果在非Macintosh平台上编码或解码文本文件它们仍将使用旧的Macintosh换行约定回车作为行尾</span></p><p><span class="yiyi-st" id="yiyi-32">在撰写本文时,<a class="reference internal" href="#binhex.hexbin" title="binhex.hexbin"><code class="xref py py-func docutils literal"><span class="pre">hexbin()</span></code></a>似乎在所有情况下都无法正常工作。</span></p></div></div></div>