@@ -325,6 +325,10 @@ msgid ""
325325"running the interpreter with the ``-Q`` flag. If you have not been doing "
326326"this then you will need to go through your code and do two things:"
327327msgstr ""
328+ "在 Python 3 中,``5 / 2 == 2.5`` 而不是 Python 2 中 ``2``;所有 ``int`` 值之间的除法都会得到一个 "
329+ "``float`` 值。 这个变化实际上从 2002 年发布的 Python 2.2 就已经计划好了。 从那时起我们就鼓励用户在所有使用 ``/`` 和"
330+ " ``//`` 运算符的文件中添加 ``from __future__ import division``,或者附带 ``-Q`` 旗标运行解释器。 "
331+ "如果你没有这样做,那么你需要检查你的代码并做两件事:"
328332
329333#: ../../howto/pyporting.rst:158
330334msgid "Add ``from __future__ import division`` to your files"
@@ -374,6 +378,8 @@ msgid ""
374378"both, it does mean you might have to now care about when you are using text "
375379"compared to binary data, which is why this cannot be entirely automated."
376380msgstr ""
381+ "Python 3 将文本和二进制数据区分为不同的类型而不能简单地混合在一起。 对于任何只处理文本或二进制数据的代码来说,这种区分并不构成问题。 "
382+ "但对于必须同时处理这两者的代码来说,这就意味着你现在可能必须关注何时使用文本而不是二进制数据,这也是为什么这无法完全自动化地操作。"
377383
378384#: ../../howto/pyporting.rst:186
379385msgid ""
@@ -389,6 +395,12 @@ msgid ""
389395"Python 3, for binary that's ``str``/``bytes`` in Python 2 and ``bytes`` in "
390396"Python 3)."
391397msgstr ""
398+ "决定哪些 API 接受文本而哪些接受二进制数据 (**强烈** 建议不要设计同时接受这两种数据的 API "
399+ "因为这很难保证代码正常工作;如前所述这一点是很难做好的)。 在 Python 2 中这意味着要确保处理文本的 API 可以使用 ``unicode`` "
400+ "而处理二进制数据的 API 可以使用来自 Python 3 的 ``bytes`` 类型 (它是 Python 2 中 ``str`` 的子集并被作为 "
401+ "Python 2 中 ``bytes`` 类型的别名)。 通常最大的问题是要意识到哪些方法在 Python 2 和 Python 3 "
402+ "的哪些类型中同时存在 (对于文本来说在 Python 2 中是 ``unicode`` 而在 Python 3 中则是 "
403+ "``str``,对于二进制数据来说在 Python 2 中是 ``str``/``bytes`` 而在 Python 3 中则是 ``bytes``)。"
392404
393405#: ../../howto/pyporting.rst:197
394406msgid ""
@@ -399,6 +411,9 @@ msgid ""
399411"Python 3 doesn't have the method). Do note that as of Python 3.5 the "
400412"``__mod__`` method was added to the bytes type."
401413msgstr ""
414+ "下表列出了每种数据类型在 Python 2 和 3 中的 **特有** 方法(例如,``decode()`` 方法在 Python 2 或 3 "
415+ "中都可用于等价的二进制数据类型,但文本数据类型无法在 Python 2 和 3 之间以一致的方式使用它因为 Python 3 中的 ``str`` "
416+ "没有该方法)。 请注意从 Python 3.5 起 bytes 类型增加了 ``__mod__`` 方法。"
402417
403418#: ../../howto/pyporting.rst:205
404419msgid "**Text data**"
0 commit comments