“Python/docs/3.9/library/binhex”的版本间差异

来自菜鸟教程
Python/docs/3.9/library/binhex
跳转至:导航、​搜索
(autoload)
 
(Page commit)
 
第1行: 第1行:
 +
{{DISPLAYTITLE:binhex — 编码和解码 binhex4 文件 — Python 文档}}
 
<div id="module-binhex" class="section">
 
<div id="module-binhex" class="section">
  
 
<span id="binhex-encode-and-decode-binhex4-files"></span>
 
<span id="binhex-encode-and-decode-binhex4-files"></span>
= [[#module-binhex|<code>binhex</code>]] --- Encode and decode binhex4 files =
+
= binhex — 编码和解码 binhex4 文件 =
  
'''Source code:''' [https://github.com/python/cpython/tree/3.9/Lib/binhex.py Lib/binhex.py]
+
'''源代码:''' [[#id1|<span id="id2" class="problematic">:source:`Lib/binhex.py`</span>]]
  
 
<div class="deprecated">
 
<div class="deprecated">
  
<span class="versionmodified deprecated">3.9 版后已移除.</span>
+
<span class="versionmodified deprecated">3.9 版起已弃用。</span>
  
  
 
</div>
 
</div>
This module encodes and decodes files in binhex4 format, a format allowing
 
representation of Macintosh files in ASCII. Only the data fork is handled.
 
  
The [[#module-binhex|<code>binhex</code>]] module defines the following functions:
+
-----
  
; <code>binhex.</code><code>binhex</code><span class="sig-paren">(</span>''<span class="n">input</span>'', ''<span class="n">output</span>''<span class="sig-paren">)</span>
+
该模块以 binhex4 格式对文件进行编码和解码,这种格式允许以 ASCII 表示 Macintosh 文件。 只处理数据叉。
: Convert a binary file with filename ''input'' to binhex file ''output''. The ''output'' parameter can either be a filename or a file-like object (any object supporting a <code>write()</code> and <code>close()</code> method).
 
  
; <code>binhex.</code><code>hexbin</code><span class="sig-paren">(</span>''<span class="n">input</span>'', ''<span class="n">output</span>''<span class="sig-paren">)</span>
+
[[#module-binhex|binhex]] 模块定义了以下函数:
: Decode a binhex file ''input''. ''input'' may be a filename or a file-like object supporting <code>read()</code> and <code>close()</code> methods. The resulting file is written to a file named ''output'', unless the argument is <code>None</code> in which case the output filename is read from the binhex file.
 
  
The following exception is also defined:
+
; <span class="sig-prename descclassname"><span class="pre">binhex.</span></span><span class="sig-name descname"><span class="pre">binhex</span></span><span class="sig-paren">(</span>''<span class="n"><span class="pre">input</span></span>'', ''<span class="n"><span class="pre">output</span></span>''<span class="sig-paren">)</span>
 +
: 将文件名 ''input'' 的二进制文件转换为 binhex 文件 ''output''。 ''output'' 参数可以是文件名或类似文件的对象(任何支持 <code>write()</code> 和 <code>close()</code> 方法的对象)。
  
; ''exception'' <code>binhex.</code><code>Error</code>
+
; <span class="sig-prename descclassname"><span class="pre">binhex.</span></span><span class="sig-name descname"><span class="pre">hexbin</span></span><span class="sig-paren">(</span>''<span class="n"><span class="pre">input</span></span>'', ''<span class="n"><span class="pre">output</span></span>''<span class="sig-paren">)</span>
: Exception raised when something can't be encoded using the binhex format (for example, a filename is too long to fit in the filename field), or when input is not properly encoded binhex data.
+
: 解码二进制文件 ''输入'' 。 ''input'' 可以是支持 <code>read()</code> 和 <code>close()</code> 方法的文件名或类文件对象。 结果文件被写入一个名为 ''output'' 的文件,除非参数是 <code>None</code>,在这种情况下,输出文件名是从 binhex 文件中读取的。
 +
 
 +
还定义了以下异常:
 +
 
 +
; ''<span class="pre">exception</span>'' <span class="sig-prename descclassname"><span class="pre">binhex.</span></span><span class="sig-name descname"><span class="pre">Error</span></span>
 +
: 当无法使用 binhex 格式编码某些内容时引发异常(例如,文件名太长而无法放入文件名字段),或者当输入未正确编码 binhex 数据时。
  
 
<div class="admonition seealso">
 
<div class="admonition seealso">
  
参见
+
也可以看看
  
; Module [[../binascii#module-binascii|<code>binascii</code>]]
+
; 模块[[../binascii#module-binascii|binascii]]
: Support module containing ASCII-to-binary and binary-to-ASCII conversions.
+
: 包含 ASCII 到二进制和二进制到 ASCII 转换的支持模块。
  
  
第40行: 第43行:
  
 
<span id="binhex-notes"></span>
 
<span id="binhex-notes"></span>
== Notes ==
+
== 笔记 ==
 +
 
 +
编码器和解码器有一个替代的、更强大的接口,详细信息请参见源代码。
  
There is an alternative, more powerful interface to the coder and decoder, see
+
如果您在非 Macintosh 平台上编码或解码文本文件,它们仍将使用旧的 Macintosh 换行约定(回车作为行尾)。
the source for details.
 
  
If you code or decode textfiles on non-Macintosh platforms they will still use
 
the old Macintosh newline convention (carriage-return as end of line).
 
  
 +
</div>
  
 
</div>
 
</div>
 +
<div class="clearer">
 +
 +
  
 
</div>
 
</div>
  
[[Category:Python 3.9 中文文档]]
+
[[Category:Python 3.9 文档]]

2021年10月31日 (日) 04:51的最新版本

binhex — 编码和解码 binhex4 文件

源代码: :source:`Lib/binhex.py`

自 3.9 版起已弃用。



该模块以 binhex4 格式对文件进行编码和解码,这种格式允许以 ASCII 表示 Macintosh 文件。 只处理数据叉。

binhex 模块定义了以下函数:

binhex.binhex(input, output)
将文件名 input 的二进制文件转换为 binhex 文件 outputoutput 参数可以是文件名或类似文件的对象(任何支持 write()close() 方法的对象)。
binhex.hexbin(input, output)
解码二进制文件 输入input 可以是支持 read()close() 方法的文件名或类文件对象。 结果文件被写入一个名为 output 的文件,除非参数是 None,在这种情况下,输出文件名是从 binhex 文件中读取的。

还定义了以下异常:

exception binhex.Error
当无法使用 binhex 格式编码某些内容时引发异常(例如,文件名太长而无法放入文件名字段),或者当输入未正确编码 binhex 数据时。

也可以看看

模块binascii
包含 ASCII 到二进制和二进制到 ASCII 转换的支持模块。


笔记

编码器和解码器有一个替代的、更强大的接口,详细信息请参见源代码。

如果您在非 Macintosh 平台上编码或解码文本文件,它们仍将使用旧的 Macintosh 换行约定(回车作为行尾)。