binhex
— Encode and decode binhex4 files对binhex4文件进行编码和解码¶
Source code: Lib/binhex.py
Deprecated since version 3.9.自3.9版起已弃用。
This module encodes and decodes files in binhex4 format, a format allowing representation of Macintosh files in ASCII. 该模块对binhex4格式的文件进行编码和解码,这种格式允许以ASCII表示Macintosh文件。Only the data fork is handled.只处理数据分叉。
The binhex
module defines the following functions:binhex
模块定义以下功能:
-
binhex.
binhex
(input, output)¶ Convert a binary file with filename input to binhex file output.将带有文件名input的二进制文件转换为十六进制文件output。The output parameter can either be a filename or a file-like object (any object supporting aoutput参数可以是文件名或类似文件的对象(任何支持write()
andclose()
method).write()
和close()
方法的对象)。
-
binhex.
hexbin
(input, output)¶ Decode a binhex file input.解码十六进制文件input。input may be a filename or a file-like object supportinginput可以是支持read()
andclose()
methods.read()
和close()
方法的文件名或类似文件的对象。The resulting file is written to a file named output, unless the argument is生成的文件将写入名为output的文件,除非参数为None
in which case the output filename is read from the binhex file.None
,否则输出文件名将从binhex文件中读取。
The following exception is also defined:还定义了以下例外情况:
-
exception
binhex.
Error
¶ 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.当无法使用binhex格式对某些内容进行编码时(例如,文件名太长,无法放入文件名字段),或者当输入未正确编码binhex数据时,引发异常。
See also
- Module
binascii
Support module containing ASCII-to-binary and binary-to-ASCII conversions.支持包含ASCII到二进制和二进制到ASCII转换的模块。
Notes¶
There is an alternative, more powerful interface to the coder and decoder, see 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).如果您在非Macintosh平台上对文本文件进行编码或解码,它们仍将使用旧的Macintosh换行符约定(回车作为行尾)。