# SOME DESCRIPTIVE TITLE. # Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # FIRST AUTHOR , YEAR. # # Translators: # python-doc bot, 2025 # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.9\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-09-22 21:56+0000\n" "PO-Revision-Date: 2025-09-22 17:54+0000\n" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/bz2.rst:2 msgid ":mod:`bz2` --- Support for :program:`bzip2` compression" msgstr ":mod:`bz2` --- 对 :program:`bzip2` 压缩算法的支持" #: ../../library/bz2.rst:12 msgid "**Source code:** :source:`Lib/bz2.py`" msgstr "**源代码:** :source:`Lib/bz2.py`" #: ../../library/bz2.rst:16 msgid "" "This module provides a comprehensive interface for compressing and " "decompressing data using the bzip2 compression algorithm." msgstr "此模块提供了使用 bzip2 压缩算法压缩和解压数据的一套完整的接口。" #: ../../library/bz2.rst:19 msgid "The :mod:`bz2` module contains:" msgstr ":mod:`bz2` 模块包含:" #: ../../library/bz2.rst:21 msgid "" "The :func:`.open` function and :class:`BZ2File` class for reading and " "writing compressed files." msgstr "用于读写压缩文件的 :func:`.open` 函数和 :class:`BZ2File` 类。" #: ../../library/bz2.rst:23 msgid "" "The :class:`BZ2Compressor` and :class:`BZ2Decompressor` classes for " "incremental (de)compression." msgstr "用于增量压缩和解压的 :class:`BZ2Compressor` 和 :class:`BZ2Decompressor` 类。" #: ../../library/bz2.rst:25 msgid "" "The :func:`compress` and :func:`decompress` functions for one-shot " "(de)compression." msgstr "用于一次性压缩和解压的 :func:`compress` 和 :func:`decompress` 函数。" #: ../../library/bz2.rst:28 msgid "" "All of the classes in this module may safely be accessed from multiple " "threads." msgstr "" #: ../../library/bz2.rst:32 msgid "(De)compression of files" msgstr "文件压缩和解压" #: ../../library/bz2.rst:36 msgid "" "Open a bzip2-compressed file in binary or text mode, returning a :term:`file" " object`." msgstr "以二进制或文本模式打开 bzip2 压缩文件,返回一个 :term:`file object`。" #: ../../library/bz2.rst:39 msgid "" "As with the constructor for :class:`BZ2File`, the *filename* argument can be" " an actual filename (a :class:`str` or :class:`bytes` object), or an " "existing file object to read from or write to." msgstr "" "和 :class:`BZ2File` 的构造函数类似,*filename* 参数可以是一个实际的文件名(:class:`str` 或 " ":class:`bytes` 对象),或是已有的可供读取或写入的文件对象。" #: ../../library/bz2.rst:43 msgid "" "The *mode* argument can be any of ``'r'``, ``'rb'``, ``'w'``, ``'wb'``, " "``'x'``, ``'xb'``, ``'a'`` or ``'ab'`` for binary mode, or ``'rt'``, " "``'wt'``, ``'xt'``, or ``'at'`` for text mode. The default is ``'rb'``." msgstr "" "*mode* 参数可设为二进制模式的 " "``'r'``、``'rb'``、``'w'``、``'wb'``、``'x'``、``'xb'``、``'a'`` 或 " "``'ab'``,或者文本模式的 ``'rt'``、``'wt'``、``'xt'`` 或 ``'at'``。默认是 ``'rb'``。" #: ../../library/bz2.rst:47 msgid "" "The *compresslevel* argument is an integer from 1 to 9, as for the " ":class:`BZ2File` constructor." msgstr "*compresslevel* 参数是 1 到 9 的整数,和 :class:`BZ2File` 的构造函数一样。" #: ../../library/bz2.rst:50 msgid "" "For binary mode, this function is equivalent to the :class:`BZ2File` " "constructor: ``BZ2File(filename, mode, compresslevel=compresslevel)``. In " "this case, the *encoding*, *errors* and *newline* arguments must not be " "provided." msgstr "" "对于二进制模式,这个函数等价于 :class:`BZ2File` 构造器: ``BZ2File(filename, mode, " "compresslevel=compresslevel)``。 在这种情况下,不可提供 *encoding*, *errors* 和 *newline*" " 参数。" #: ../../library/bz2.rst:55 msgid "" "For text mode, a :class:`BZ2File` object is created, and wrapped in an " ":class:`io.TextIOWrapper` instance with the specified encoding, error " "handling behavior, and line ending(s)." msgstr "" "对于文本模式,将会创建一个 :class:`BZ2File` 对象,并将它包装到一个 :class:`io.TextIOWrapper` " "实例中,此实例带有指定的编码格式、错误处理行为和行结束符。" #: ../../library/bz2.rst:61 ../../library/bz2.rst:126 msgid "The ``'x'`` (exclusive creation) mode was added." msgstr "添加了 ``'x'`` (单独创建) 模式。" #: ../../library/bz2.rst:64 ../../library/bz2.rst:133 msgid "Accepts a :term:`path-like object`." msgstr "接受一个 :term:`path-like object`。" #: ../../library/bz2.rst:70 msgid "Open a bzip2-compressed file in binary mode." msgstr "用二进制模式打开 bzip2 压缩文件。" #: ../../library/bz2.rst:72 msgid "" "If *filename* is a :class:`str` or :class:`bytes` object, open the named " "file directly. Otherwise, *filename* should be a :term:`file object`, which " "will be used to read or write the compressed data." msgstr "" "如果 *filename* 是一个 :class:`str` 或 :class:`bytes` 对象,则打开名称对应的文件目录。 " "否则的话,*filename* 应当是一个 :term:`file object`,它将被用来读取或写入压缩数据。" #: ../../library/bz2.rst:76 msgid "" "The *mode* argument can be either ``'r'`` for reading (default), ``'w'`` for" " overwriting, ``'x'`` for exclusive creation, or ``'a'`` for appending. " "These can equivalently be given as ``'rb'``, ``'wb'``, ``'xb'`` and ``'ab'``" " respectively." msgstr "" "*mode* 参数可以是表示读取的 ``'r'`` (默认值),表示覆写的 ``'w'``,表示单独创建的 ``'x'``,或表示添加的 " "``'a'``。 这些模式还可分别以 ``'rb'``, ``'wb'``, ``'xb'`` 和 ``'ab'`` 的等价形式给出。" #: ../../library/bz2.rst:81 msgid "" "If *filename* is a file object (rather than an actual file name), a mode of " "``'w'`` does not truncate the file, and is instead equivalent to ``'a'``." msgstr "如果 *filename* 是一个文件对象(而不是实际的文件名),则 ``'w'`` 模式并不会截断文件,而是会等价于 ``'a'``。" #: ../../library/bz2.rst:84 msgid "" "If *mode* is ``'w'`` or ``'a'``, *compresslevel* can be an integer between " "``1`` and ``9`` specifying the level of compression: ``1`` produces the " "least compression, and ``9`` (default) produces the most compression." msgstr "" "如果 *mode* 为 ``'w'`` 或 ``'a'``,则 *compresslevel* 可以是 ``1`` 到 ``9`` " "之间的整数,用于指定压缩等级: ``1`` 产生最低压缩率,而 ``9`` (默认值) 产生最高压缩率。" #: ../../library/bz2.rst:88 msgid "" "If *mode* is ``'r'``, the input file may be the concatenation of multiple " "compressed streams." msgstr "如果 *mode* 为 ``'r'``,则输入文件可以为多个压缩流的拼接。" #: ../../library/bz2.rst:91 msgid "" ":class:`BZ2File` provides all of the members specified by the " ":class:`io.BufferedIOBase`, except for :meth:`detach` and :meth:`truncate`. " "Iteration and the :keyword:`with` statement are supported." msgstr "" ":class:`BZ2File` 提供了 :class:`io.BufferedIOBase` 所指定的所有成员,但 :meth:`detach` 和 " ":meth:`truncate` 除外。 并支持迭代和 :keyword:`with` 语句。" #: ../../library/bz2.rst:95 msgid ":class:`BZ2File` also provides the following method:" msgstr ":class:`BZ2File` 还提供了以下方法:" #: ../../library/bz2.rst:99 msgid "" "Return buffered data without advancing the file position. At least one byte " "of data will be returned (unless at EOF). The exact number of bytes returned" " is unspecified." msgstr "返回缓冲的数据而不前移文件位置。 至少将返回一个字节的数据(除非为 EOF)。 实际返回的字节数不确定。" #: ../../library/bz2.rst:103 msgid "" "While calling :meth:`peek` does not change the file position of the " ":class:`BZ2File`, it may change the position of the underlying file object " "(e.g. if the :class:`BZ2File` was constructed by passing a file object for " "*filename*)." msgstr "" "虽然调用 :meth:`peek` 不会改变 :class:`BZ2File` 的文件位置,但它可能改变下层文件对象的位置(举例来说如果 " ":class:`BZ2File` 是通过传入一个文件对象作为 *filename* 的话)。" #: ../../library/bz2.rst:111 msgid "Support for the :keyword:`with` statement was added." msgstr "添加了对 :keyword:`with` 语句的支持。" #: ../../library/bz2.rst:114 msgid "" "The :meth:`fileno`, :meth:`readable`, :meth:`seekable`, :meth:`writable`, " ":meth:`read1` and :meth:`readinto` methods were added." msgstr "" "添加了 :meth:`fileno`, :meth:`readable`, :meth:`seekable`, :meth:`writable`, " ":meth:`read1` 和 :meth:`readinto` 方法。" #: ../../library/bz2.rst:118 msgid "" "Support was added for *filename* being a :term:`file object` instead of an " "actual filename." msgstr "添加了对 *filename* 使用 :term:`file object` 而非实际文件名的支持。" #: ../../library/bz2.rst:122 msgid "" "The ``'a'`` (append) mode was added, along with support for reading multi-" "stream files." msgstr "添加了 ``'a'`` (append) 模式,以及对读取多数据流文件的支持。" #: ../../library/bz2.rst:129 msgid "" "The :meth:`~io.BufferedIOBase.read` method now accepts an argument of " "``None``." msgstr ":meth:`~io.BufferedIOBase.read` 方法现在接受 ``None`` 作为参数。" #: ../../library/bz2.rst:136 msgid "" "The *buffering* parameter has been removed. It was ignored and deprecated " "since Python 3.0. Pass an open file object to control how the file is " "opened." msgstr "*buffering* 形参已被移除。 它自 Python 3.0 起即被忽略并弃用。 请传入一个打开文件对象来控制文件的打开方式。" #: ../../library/bz2.rst:141 msgid "The *compresslevel* parameter became keyword-only." msgstr "*compresslevel* 形参成为仅限关键字参数。" #: ../../library/bz2.rst:145 msgid "Incremental (de)compression" msgstr "增量压缩和解压" #: ../../library/bz2.rst:149 msgid "" "Create a new compressor object. This object may be used to compress data " "incrementally. For one-shot compression, use the :func:`compress` function " "instead." msgstr "创建一个新的压缩器对象。 此对象可被用来执行增量数据压缩。 对于一次性压缩,请改用 :func:`compress` 函数。" #: ../../library/bz2.rst:153 ../../library/bz2.rst:241 msgid "" "*compresslevel*, if given, must be an integer between ``1`` and ``9``. The " "default is ``9``." msgstr "如果给定 *compresslevel*,它必须为 ``1`` 至 ``9`` 之间的整数。 默认值为 ``9``。" #: ../../library/bz2.rst:158 msgid "" "Provide data to the compressor object. Returns a chunk of compressed data if" " possible, or an empty byte string otherwise." msgstr "向压缩器对象提供数据。 在可能的情况下返回一段已压缩数据,否则返回空字节串。" #: ../../library/bz2.rst:161 msgid "" "When you have finished providing data to the compressor, call the " ":meth:`flush` method to finish the compression process." msgstr "当你已结束向压缩器提供数据时,请调用 :meth:`flush` 方法来完成压缩进程。" #: ../../library/bz2.rst:167 msgid "" "Finish the compression process. Returns the compressed data left in internal" " buffers." msgstr "结束压缩进程,返回内部缓冲中剩余的压缩完成的数据。" #: ../../library/bz2.rst:170 msgid "" "The compressor object may not be used after this method has been called." msgstr "调用此方法之后压缩器对象将不可再被使用。" #: ../../library/bz2.rst:175 msgid "" "Create a new decompressor object. This object may be used to decompress data" " incrementally. For one-shot compression, use the :func:`decompress` " "function instead." msgstr "创建一个新的解压缩器对象。 此对象可被用来执行增量数据解压缩。 对于一次性解压缩,请改用 :func:`decompress` 函数。" #: ../../library/bz2.rst:180 msgid "" "This class does not transparently handle inputs containing multiple " "compressed streams, unlike :func:`decompress` and :class:`BZ2File`. If you " "need to decompress a multi-stream input with :class:`BZ2Decompressor`, you " "must use a new decompressor for each stream." msgstr "" "这个类不会透明地处理包含多个已压缩数据流的输入,这不同于 :func:`decompress` 和 :class:`BZ2File`。 如果你需要通过 " ":class:`BZ2Decompressor` 来解压缩多个数据流输入,你必须为每个数据流都使用新的解压缩器。" #: ../../library/bz2.rst:187 msgid "" "Decompress *data* (a :term:`bytes-like object`), returning uncompressed data" " as bytes. Some of *data* may be buffered internally, for use in later calls" " to :meth:`decompress`. The returned data should be concatenated with the " "output of any previous calls to :meth:`decompress`." msgstr "" "解压缩 *data* (一个 :term:`bytes-like object`),返回字节串形式的解压缩数据。 某些 *data* " "可以在内部被缓冲,以便用于后续的 :meth:`decompress` 调用。 返回的数据应当与之前任何 :meth:`decompress` " "调用的输出进行拼接。" #: ../../library/bz2.rst:193 msgid "" "If *max_length* is nonnegative, returns at most *max_length* bytes of " "decompressed data. If this limit is reached and further output can be " "produced, the :attr:`~.needs_input` attribute will be set to ``False``. In " "this case, the next call to :meth:`~.decompress` may provide *data* as " "``b''`` to obtain more of the output." msgstr "" "如果 *max_length* 为非负数,将返回至多 *max_length* 个字节的解压缩数据。 如果达到此限制并且可以产生后续输出,则 " ":attr:`~.needs_input` 属性将被设为 ``False``。 在这种情况下,下一次 :meth:`~.decompress` " "调用提供的 *data* 可以为 ``b''`` 以获取更多的输出。" #: ../../library/bz2.rst:200 msgid "" "If all of the input data was decompressed and returned (either because this " "was less than *max_length* bytes, or because *max_length* was negative), the" " :attr:`~.needs_input` attribute will be set to ``True``." msgstr "" "如果所有输入数据都已被解压缩并返回(或是因为它少于 *max_length* 个字节,或是因为 *max_length* 为负数),则 " ":attr:`~.needs_input` 属性将被设为 ``True``。" #: ../../library/bz2.rst:205 msgid "" "Attempting to decompress data after the end of stream is reached raises an " "`EOFError`. Any data found after the end of the stream is ignored and saved" " in the :attr:`~.unused_data` attribute." msgstr "" #: ../../library/bz2.rst:209 msgid "Added the *max_length* parameter." msgstr "添加了 *max_length* 形参。" #: ../../library/bz2.rst:214 msgid "``True`` if the end-of-stream marker has been reached." msgstr "若达到了数据流的末尾标记则为 ``True``。" #: ../../library/bz2.rst:221 msgid "Data found after the end of the compressed stream." msgstr "在压缩数据流的末尾之后获取的数据。" #: ../../library/bz2.rst:223 msgid "" "If this attribute is accessed before the end of the stream has been reached," " its value will be ``b''``." msgstr "如果在达到数据流末尾之前访问此属性,其值将为 ``b''``。" #: ../../library/bz2.rst:228 msgid "" "``False`` if the :meth:`.decompress` method can provide more decompressed " "data before requiring new uncompressed input." msgstr "如果在要求新的未解压缩输入之前 :meth:`.decompress` 方法可以提供更多的解压缩数据则为 ``False``。" #: ../../library/bz2.rst:235 msgid "One-shot (de)compression" msgstr "一次性压缩或解压缩" #: ../../library/bz2.rst:239 msgid "Compress *data*, a :term:`bytes-like object `." msgstr "压缩 *data*,此参数为一个 :term:`字节类对象 `。" #: ../../library/bz2.rst:244 msgid "For incremental compression, use a :class:`BZ2Compressor` instead." msgstr "对于增量压缩,请改用 :class:`BZ2Compressor`。" #: ../../library/bz2.rst:249 msgid "Decompress *data*, a :term:`bytes-like object `." msgstr "解压缩 *data*,此参数为一个 :term:`字节类对象 `。" #: ../../library/bz2.rst:251 msgid "" "If *data* is the concatenation of multiple compressed streams, decompress " "all of the streams." msgstr "如果 *data* 是多个压缩数据流的拼接,则解压缩所有数据流。" #: ../../library/bz2.rst:254 msgid "For incremental decompression, use a :class:`BZ2Decompressor` instead." msgstr "对于增量解压缩,请改用 :class:`BZ2Decompressor`。" #: ../../library/bz2.rst:256 msgid "Support for multi-stream inputs was added." msgstr "支持了多数据流的输入。" #: ../../library/bz2.rst:262 msgid "Examples of usage" msgstr "用法示例" #: ../../library/bz2.rst:264 msgid "Below are some examples of typical usage of the :mod:`bz2` module." msgstr "以下是 :mod:`bz2` 模块典型用法的一些示例。" #: ../../library/bz2.rst:266 msgid "" "Using :func:`compress` and :func:`decompress` to demonstrate round-trip " "compression:" msgstr "使用 :func:`compress` 和 :func:`decompress` 来显示往复式的压缩:" #: ../../library/bz2.rst:284 msgid "Using :class:`BZ2Compressor` for incremental compression:" msgstr "使用 :class:`BZ2Compressor` 进行增量压缩:" #: ../../library/bz2.rst:302 msgid "" "The example above uses a very \"nonrandom\" stream of data (a stream of " "`b\"z\"` chunks). Random data tends to compress poorly, while ordered, " "repetitive data usually yields a high compression ratio." msgstr "" #: ../../library/bz2.rst:306 msgid "Writing and reading a bzip2-compressed file in binary mode:" msgstr "用二进制模式写入和读取 bzip2 压缩文件:"