@@ -1164,6 +1164,7 @@ msgid ""
11641164"names of the functions. This is also the primary technique used to emulate "
11651165"a case construct::"
11661166msgstr ""
1167+ "最好的做法是使用一个将字符串映射到函数的字典。 这一技巧的主要优势在于字符串不必与函数名称一致。 这也是用于模拟其他语言中 case 结构的主要技巧::"
11671168
11681169#: ../../faq/programming.rst:941
11691170msgid "Use the built-in function :func:`getattr`::"
@@ -1173,22 +1174,22 @@ msgstr "使用内置函数 :func:`getattr` ::"
11731174msgid ""
11741175"Note that :func:`getattr` works on any object, including classes, class "
11751176"instances, modules, and so on."
1176- msgstr ""
1177+ msgstr "请注意 :func:`getattr` 可用于任何对象,包括类、类实例、模块等等。 "
11771178
11781179#: ../../faq/programming.rst:949
11791180msgid "This is used in several places in the standard library, like this::"
1180- msgstr ""
1181+ msgstr "在标准库中多次使用了这个技巧,例如:: "
11811182
11821183#: ../../faq/programming.rst:962
11831184msgid "Use :func:`locals` or :func:`eval` to resolve the function name::"
1184- msgstr ""
1185+ msgstr "使用 :func:`locals` 或 :func:`eval` 来解析出函数名:: "
11851186
11861187#: ../../faq/programming.rst:975
11871188msgid ""
11881189"Note: Using :func:`eval` is slow and dangerous. If you don't have absolute "
11891190"control over the contents of the string, someone could pass a string that "
11901191"resulted in an arbitrary function being executed."
1191- msgstr ""
1192+ msgstr "注意:使用 :func:`eval` 速度慢而且危险。 如果你不能绝对掌控字符串的内容,别人将能传入可被解析为任意函数直接执行的字符串。 "
11921193
11931194#: ../../faq/programming.rst:980
11941195msgid ""
@@ -1215,11 +1216,11 @@ msgstr "由于通常只在一次读取一行文本时才需要这样做,所以
12151216
12161217#: ../../faq/programming.rst:999
12171218msgid "Is there a scanf() or sscanf() equivalent?"
1218- msgstr ""
1219+ msgstr "是否有 scanf() 或 sscanf() 的对应物? "
12191220
12201221#: ../../faq/programming.rst:1001
12211222msgid "Not as such."
1222- msgstr "不是这样的 。"
1223+ msgstr "没有这样的对应物 。"
12231224
12241225#: ../../faq/programming.rst:1003
12251226msgid ""
@@ -1230,12 +1231,15 @@ msgid ""
12301231"parameter which is useful if the line uses something other than whitespace "
12311232"as a separator."
12321233msgstr ""
1234+ "对于简单的输入解析,最方便的做法通常是使用字符串对象的 :meth:`~str.split` 方法将一行内容拆解为以空格分隔的单词,然后使用 "
1235+ ":func:`int` 或 :func:`float` 将表示十进制数的字符串转换为数值。 ``split()`` 支持可选的 \" sep\" "
1236+ "形参,适用于内容行使用空格符以外的分隔符的情况。"
12331237
12341238#: ../../faq/programming.rst:1009
12351239msgid ""
12361240"For more complicated input parsing, regular expressions are more powerful "
12371241"than C's :c:func:`sscanf` and better suited for the task."
1238- msgstr ""
1242+ msgstr "以于更复杂的输入解析,正则表达式会比 C 的 :c:func:`sscanf` 更强大,也更适合此类任务。 "
12391243
12401244#: ../../faq/programming.rst:1014
12411245msgid "What does 'UnicodeDecodeError' or 'UnicodeEncodeError' error mean?"
@@ -1345,10 +1349,10 @@ msgid ""
13451349"skills, you can also :ref:`write a C extension module <extending-index>` "
13461350"yourself."
13471351msgstr ""
1348- "如果你已经达到纯Python允许的限制 ,那么有一些工具可以让你走得更远。例如, `Cython <http://cython.org>`_ "
1349- "可以将稍微修改的Python代码版本编译为C扩展 ,并且可以在许多不同的平台上使用。 "
1350- "Cython可以利用编译 (和可选的类型注释)来使代码明显快于解释时的速度。如果您对C编程技能有信心,也可以自己编写 :ref:`write a C "
1351- "extension module <extending-index>` 。"
1352+ "如果你已经达到纯 Python 允许的限制 ,那么有一些工具可以让你走得更远。 例如, `Cython <http://cython.org>`_ "
1353+ "可以将稍微修改的 Python 代码版本编译为 C 扩展 ,并且可以在许多不同的平台上使用。 Cython "
1354+ "可以利用编译 (和可选的类型注释)来使代码明显快于解释运行时的速度。 如果您对 C 编程技能有信心,也可以自己 :ref:`编写 C 扩展模块 "
1355+ "<extending-index>` 。"
13521356
13531357#: ../../faq/programming.rst:1075
13541358msgid ""
0 commit comments