Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 82600a6

Browse files
[po] auto sync
1 parent 8166acd commit 82600a6

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

.stat.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"translation": "90.80%", "updated_at": "2023-09-18T14:56:34Z"}
1+
{"translation": "90.81%", "updated_at": "2023-09-18T15:56:54Z"}

howto/pyporting.po

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,9 @@ msgid ""
468468
"unspecified literals to be Unicode, but usage has shown it isn't as "
469469
"effective as adding a ``b`` or ``u`` prefix to all literals explicitly)"
470470
msgstr ""
471+
"下一个问题是确保你知道你的代码中的字符串字面值是代表文本还是二进制数据。 你应当给任何代表二进制数据的字面值添加 ``b`` 前缀。 "
472+
"对于文本则应当给文本字面值添加 ``u`` 前缀。 (有一个 :mod:`__future__` 导入可以强制所有未指定前缀的字面值为 "
473+
"Unicode,但实际使用情况表明它并不像给所有字面值显式地添加 ``b`` 或 ``u`` 前缀那样有效)。"
471474

472475
#: ../../howto/pyporting.rst:232
473476
msgid ""
@@ -485,6 +488,12 @@ msgid ""
485488
" :func:`codecs.open` as that's only necessary for keeping compatibility with"
486489
" Python 2.5."
487490
msgstr ""
491+
"对于打开文件你也需要小心。 在打开二进制文件时你可能并不总是会特意添加 ``b`` 模式 (例如,``rb`` 表示二进制读取)。 在 Python 3"
492+
" 中,二进制文件和文本文件是截然不同且互不兼容的;详情参见 :mod:`io` 模块。 因此,你 **必须** 决定一个文件要用于二进制访问 "
493+
"(允许读取和/或写入二进制数据) 还是文本访问 (允许读取和/或写入文本数据)。 你还应当使用 :func:`io.open` "
494+
"来打开文件而不是使用内置的 :func:`open` 函数因为 :mod:`io` 模块从 Python 2 到 3 是保持一致的而内置的 "
495+
":func:`open` 函数并非如此 (在 Python 3 中它实际上是 :func:`io.open`)。 请不要使用 "
496+
":func:`codecs.open` 这种过时的做法因为它仅在保持与 Python 2.5 的兼容时才是必要的。"
488497

489498
#: ../../howto/pyporting.rst:245
490499
msgid ""
@@ -498,6 +507,12 @@ msgid ""
498507
"object back: ``str(b'3') == b'3'``. But in Python 3 you get the string "
499508
"representation of the bytes object: ``str(b'3') == \"b'3'\"``."
500509
msgstr ""
510+
"``str`` 和 ``bytes`` 的构造器在 Python 2 和 3 中对相同的参数有不同的语义。 在 Python 2 中,向 "
511+
"``bytes`` 传入一个整数会得到该整数的字符串表示形式: ``bytes(3) == '3'``。 但在 Python 3 中,向 "
512+
"``bytes`` 传入一个整数参数则会得到一个该整数所指定的长度的字节对象,并空字节填充: ``bytes(3) == "
513+
"b'\\x00\\x00\\x00'``。 当向 ``str`` 传入字节串对象时也同样需要注意。 在 Python 2 中你只是得到该字节串对象: "
514+
"``str(b'3') == b'3'``。 但在 Python 3 中你将得到该字节串对象的字符串表示形式: ``str(b'3') == "
515+
"\"b'3'\"``。"
501516

502517
#: ../../howto/pyporting.rst:255
503518
msgid ""
@@ -698,6 +713,9 @@ msgid ""
698713
" integrate tox with your continuous integration system so that you never "
699714
"accidentally break Python 2 or 3 support."
700715
msgstr ""
716+
"一旦你能够完全在 Python 3 下运行,你将会希望确保你的代码在 Python 2 和 3 下总是能够正常工作。 在多个 Python "
717+
"解释器下运行测试的最佳工具可能就是 tox_。 然后你可以将 tox 集成到你的持续集成系统中,这样你就不会意外地破坏对 Python 2 或 3 "
718+
"的支持。"
701719

702720
#: ../../howto/pyporting.rst:386
703721
msgid ""

0 commit comments

Comments
 (0)