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()
andclose()
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转换。