18.13. binhex — 对binhex4文件进行编码和解码

This module encodes and decodes files in binhex4 format, a format allowing representation of Macintosh files in ASCII. On the Macintosh, both forks of a file and the finder information are encoded (or decoded), on other platforms only the data fork is handled.

注解

In Python 3.x, special Macintosh support has been removed.

binhex 模块定义了以下功能:

binhex.binhex(input, output)

将带有文件名 输入 的二进制文件转换为binhex文件 输出 。输出参数可以是文件名或类文件对象( write()close() 方法的任何对象)。

binhex.hexbin(input[, output])

Decode a binhex file input. input may be a filename or a file-like object supporting read() and close() methods. The resulting file is written to a file named output, unless the argument is omitted in which case the output filename is read from the binhex file.

还定义了以下异常:

exception binhex.Error

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

参见

模块 binascii

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

18.13.1. 注释

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

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

As of this writing, hexbin() appears to not work in all cases.