@@ -151,8 +151,8 @@ msgid ""
151151":keyword:`except` keyword, the except clause is executed, and then execution"
152152" continues after the :keyword:`try` statement."
153153msgstr ""
154- "如果在执行 try 子句时发生了异常,则跳过该子句中剩下的部分。 然后,如果异常的类型和 :keyword:`except` "
155- "关键字后面的异常匹配,则执行 except 子句,然后继续执行 :keyword:`try` 语句之后的代码。"
154+ "如果执行 try 子句时发生了异常,则跳过该子句中剩下的部分。如果异常的类型与 :keyword:`except` 关键字后面的异常匹配,则执行 "
155+ "except 子句,然后,继续执行 :keyword:`try` 语句之后的代码。"
156156
157157#: ../../tutorial/errors.rst:109
158158msgid ""
@@ -161,8 +161,8 @@ msgid ""
161161"handler is found, it is an *unhandled exception* and execution stops with a "
162162"message as shown above."
163163msgstr ""
164- "如果发生的异常和 except 子句中指定的异常不匹配 ,则将其传递到外部的 :keyword:`try` 语句中;如果没有找到处理程序,则它是一个 "
165- "*未处理异常*,执行将停止并显示如上所示的消息 。"
164+ "如果发生的异常不是 except 子句中列示的异常 ,则将其传递到外部的 :keyword:`try` 语句中;如果没有找到处理程序,则它是一个 "
165+ "*未处理异常*,语句执行将终止,并显示如上所示的消息 。"
166166
167167#: ../../tutorial/errors.rst:114
168168msgid ""
@@ -172,9 +172,8 @@ msgid ""
172172"not in other handlers of the same :keyword:`!try` statement. An except "
173173"clause may name multiple exceptions as a parenthesized tuple, for example::"
174174msgstr ""
175- "一个 :keyword:`try` 语句可能有多个 except 子句,以指定不同异常的处理程序。 最多会执行一个处理程序。 处理程序只处理相应的 "
176- "try 子句中发生的异常,而不处理同一 :keyword:`!try` 语句内其他处理程序中的异常。 一个 except "
177- "子句可以将多个异常命名为带括号的元组,例如::"
175+ ":keyword:`try` 语句可以有多个 except 子句,可为不同异常指定相应的处理程序。但最多只会执行一个处理程序。处理程序只处理对应的 "
176+ "try 子句中发生的异常,而不处理同一 :keyword:`!try` 语句内其他处理程序中的异常。except 子句可以用元组命名多个异常,例如:"
178177
179178#: ../../tutorial/errors.rst:123
180179msgid ""
@@ -183,17 +182,16 @@ msgid ""
183182" an except clause listing a derived class is not compatible with a base "
184183"class). For example, the following code will print B, C, D in that order::"
185184msgstr ""
186- "如果发生的异常和 :keyword:`except` 子句中的类是同一个类或者是它的基类,则异常和 except 子句中的类是兼容的(但反过来则不成立 "
187- "--- 列出派生类的 except 子句与基类不兼容)。 例如,下面的代码将依次打印 B, C, D :: "
185+ "发生的异常与 :keyword:`except` 子句中的类是同一个类或是它的基类时,异常与 except 子句中的类兼容(反之则不成立 --- "
186+ "列出派生类的 except 子句与基类不兼容)。例如,下面的代码依次输出 B, C, D: "
188187
189188#: ../../tutorial/errors.rst:147
190189msgid ""
191190"Note that if the except clauses were reversed (with ``except B`` first), it "
192191"would have printed B, B, B --- the first matching except clause is "
193192"triggered."
194193msgstr ""
195- "请注意如果 except 子句被颠倒(把 ``except B`` 放到第一个),它将打印 B,B,B --- 即第一个匹配的 except "
196- "子句被触发。"
194+ "注意,如果 except 子句被颠倒(把 ``except B`` 放到第一个),则输出 B,B,B --- 即触发第一个匹配的 except 子句。"
197195
198196#: ../../tutorial/errors.rst:150
199197msgid ""
@@ -204,7 +202,7 @@ msgid ""
204202"exception as well)::"
205203msgstr ""
206204"最后的 except "
207- "子句可以省略异常名,以用作通配符。但请谨慎使用,因为以这种方式很容易掩盖真正的编程错误!它还可用于打印错误消息,然后重新引发异常 (同样允许调用者处理异常):: "
205+ "子句可以省略异常名,以用作通配符。但应谨慎使用,这种方式很容易掩盖真正的编程错误!它还可用于输出错误消息,然后重新触发异常 (同样允许调用者处理异常): "
208206
209207#: ../../tutorial/errors.rst:169
210208msgid ""
@@ -213,8 +211,8 @@ msgid ""
213211"for code that must be executed if the try clause does not raise an "
214212"exception. For example::"
215213msgstr ""
216- ":keyword:`try` ... :keyword:`except` 语句有一个可选的 *else 子句*,在使用时必须放在所有的 except "
217- "子句后面。对于在 try 子句不引发异常时必须执行的代码来说很有用。 例如:: "
214+ ":keyword:`try` ... :keyword:`except` 语句支持可选的 *else 子句*,该子句必须放在所有 except "
215+ "子句之后。如果 try 子句没有触发异常,但又必须执行一些代码时,这个子句很有用。例如: "
218216
219217#: ../../tutorial/errors.rst:183
220218msgid ""
@@ -223,15 +221,15 @@ msgid ""
223221"exception that wasn't raised by the code being protected by the "
224222":keyword:`!try` ... :keyword:`!except` statement."
225223msgstr ""
226- "使用 :keyword:`!else` 子句比向 :keyword:`try` 子句添加额外的代码要好,因为它避免了意外捕获非 "
227- ":keyword:`!try` ... :keyword:`!except` 语句保护的代码引发的异常 。"
224+ "使用 :keyword:`!else` 子句比向 :keyword:`try` 子句添加额外的代码要好,可以避免意外捕获非 "
225+ ":keyword:`!try` ... :keyword:`!except` 语句保护的代码触发的异常 。"
228226
229227#: ../../tutorial/errors.rst:188
230228msgid ""
231229"When an exception occurs, it may have an associated value, also known as the"
232230" exception's *argument*. The presence and type of the argument depend on the"
233231" exception type."
234- msgstr "发生异常时,它可能具有关联值,也称为异常 *参数* 。参数的存在和类型取决于异常类型 。"
232+ msgstr "发生异常时,它可能具有关联值,即异常 *参数* 。是否需要参数,以及参数的类型取决于异常的类型 。"
235233
236234#: ../../tutorial/errors.rst:192
237235msgid ""
@@ -278,14 +276,14 @@ msgid ""
278276"arguments::"
279277msgstr ""
280278":keyword:`raise` 唯一的参数就是要触发的异常。这个参数必须是异常实例或异常类(派生自 :class:`Exception` "
281- "的类 )。如果传递的是异常类,将通过调用没有参数的构造函数来隐式实例化:"
279+ "类 )。如果传递的是异常类,将通过调用没有参数的构造函数来隐式实例化:"
282280
283281#: ../../tutorial/errors.rst:254
284282msgid ""
285283"If you need to determine whether an exception was raised but don't intend to"
286284" handle it, a simpler form of the :keyword:`raise` statement allows you to "
287285"re-raise the exception::"
288- msgstr "如果你需要确定是否引发了异常但不打算处理它, 则可以使用更简单的 :keyword:`raise` 语句形式重新引发异常 :: "
286+ msgstr "如果只想判断是否触发了异常,但并不打算处理该异常, 则可以使用更简单的 :keyword:`raise` 语句重新触发异常: "
289287
290288#: ../../tutorial/errors.rst:273
291289msgid "Exception Chaining"
@@ -295,11 +293,11 @@ msgstr "异常链"
295293msgid ""
296294"The :keyword:`raise` statement allows an optional :keyword:`from<raise>` "
297295"which enables chaining exceptions. For example::"
298- msgstr ":keyword:`raise` 语句允许可选的 :keyword:`from<raise>` 子句,它启用了链式异常 。 例如:: "
296+ msgstr ":keyword:`raise` 语句支持可选的 :keyword:`from<raise>` 子句,该子句用于启用链式异常 。 例如: "
299297
300298#: ../../tutorial/errors.rst:281
301299msgid "This can be useful when you are transforming exceptions. For example::"
302- msgstr "这在要转换异常时很有用 。例如:"
300+ msgstr "转换异常时,这种方式很有用 。例如:"
303301
304302#: ../../tutorial/errors.rst:302
305303msgid ""
@@ -326,8 +324,8 @@ msgid ""
326324"typically be derived from the :exc:`Exception` class, either directly or "
327325"indirectly."
328326msgstr ""
329- "程序可以通过创建新的异常类来命名它们自己的异常(有关Python 类的更多信息,请参阅 :ref:`tut-"
330- "classes`)。异常通常应该直接或间接地从 :exc:`Exception` 类派生。"
327+ "程序可以通过创建新的异常类命名自己的异常(Python 类的内容详见 :ref:`tut-classes`)。不论是以直接还是间接的方式,异常都应从 "
328+ ":exc:`Exception` 类派生。"
331329
332330#: ../../tutorial/errors.rst:327
333331msgid ""
@@ -339,22 +337,20 @@ msgid ""
339337"module, and subclass that to create specific exception classes for different"
340338" error conditions::"
341339msgstr ""
342- "可以定义异常类,它可以执行任何其他类可以执行的任何操作,但通常保持简单,只提供一些属性,这些属性允许处理程序为异常提取有关错误的信息。 "
343- "在创建可能引发多个不同错误的模块时,通常的做法是为该模块定义的异常创建基类,并为不同错误条件创建特定异常类的子类::"
340+ "异常类和其他类一样,可以执行任何操作。但通常会比较简单,只提供让处理异常的程序提取错误信息的一些属性。创建能触发多个不同错误的模块时,一般只为该模块定义异常基类,然后再根据不同的错误条件,创建指定异常类的子类:"
344341
345342#: ../../tutorial/errors.rst:365
346343msgid ""
347344"Most exceptions are defined with names that end in \" Error\" , similar to the"
348345" naming of the standard exceptions."
349- msgstr "大多数异常都定义为名称以 “Error”结尾,类似于标准异常的命名 。"
346+ msgstr "大多数异常命名都以 “Error” 结尾,类似标准异常的命名 。"
350347
351348#: ../../tutorial/errors.rst:368
352349msgid ""
353350"Many standard modules define their own exceptions to report errors that may "
354351"occur in functions they define. More information on classes is presented in"
355352" chapter :ref:`tut-classes`."
356- msgstr ""
357- "许多标准模块定义了它们自己的异常,以报告它们定义的函数中可能出现的错误。有关类的更多信息,请参见 :ref:`tut-classes` 章节。"
353+ msgstr "许多标准模块都需要自定义异常,以报告由其定义的函数中出现的错误。有关类的说明,详见 :ref:`tut-classes`。"
358354
359355#: ../../tutorial/errors.rst:376
360356msgid "Defining Clean-up Actions"
0 commit comments