我看不到external_attr
和internal_attr
实际指的解释(如果有区别,则在python2和python3中都使用)。
https://docs.python.org/3/library/zipfile.html
有人可以提供任何细节吗?
答案 0 :(得分:0)
这很有趣,源代码也没有使它变得显而易见,而是由著名的Python开发人员David Beazley着书Python Essential Reference。
internal_attr
描述档案内容的内部结构。如果低位为1,则数据为ASCII文本。否则,将假定为二进制数据。
external_attr
依赖于操作系统的外部文件属性。
答案 1 :(得分:0)
PKZIP Application Note(在 Python docs for zipfile 中引用)声明如下:
4.4.15 external file attributes: (4 bytes) The mapping of the external attributes is host-system dependent (see 'version made by'). For MS-DOS, the low order byte is the MS-DOS directory attribute byte. If input came from standard input, this field is set to zero.
4.4.14 internal file attributes: (2 bytes) Bits 1 and 2 are reserved for use by PKWARE. 4.4.14.1 The lowest bit of this field indicates, if set, that the file is apparently an ASCII or text file. If not set, that the file apparently contains binary data. The remaining bits are unused in version 1.0. 4.4.14.2 The 0x0002 bit of this field indicates, if set, that a 4 byte variable record length control field precedes each logical record indicating the length of the record. The record length control field is stored in little-endian byte order. This flag is independent of text control characters, and if used in conjunction with text data, includes any control characters in the total length of the record. This value is provided for mainframe data transfer support.