-
-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathcompound_stmts.po
More file actions
2444 lines (2055 loc) · 108 KB
/
compound_stmts.po
File metadata and controls
2444 lines (2055 loc) · 108 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001-2025, Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# python-doc bot, 2025
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.11\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-01-03 15:28+0000\n"
"PO-Revision-Date: 2025-09-22 16:51+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"
#: ../../reference/compound_stmts.rst:5
msgid "Compound statements"
msgstr "复合语句"
#: ../../reference/compound_stmts.rst:9
msgid ""
"Compound statements contain (groups of) other statements; they affect or "
"control the execution of those other statements in some way. In general, "
"compound statements span multiple lines, although in simple incarnations a "
"whole compound statement may be contained in one line."
msgstr ""
"复合语句是包含其它语句(语句组)的语句;它们会以某种方式影响或控制所包含其它语句的执行。 "
"通常,复合语句会跨越多行,虽然在某些简单形式下整个复合语句也可能包含于一行之内。"
#: ../../reference/compound_stmts.rst:14
msgid ""
"The :keyword:`if`, :keyword:`while` and :keyword:`for` statements implement "
"traditional control flow constructs. :keyword:`try` specifies exception "
"handlers and/or cleanup code for a group of statements, while the "
":keyword:`with` statement allows the execution of initialization and "
"finalization code around a block of code. Function and class definitions "
"are also syntactically compound statements."
msgstr ""
":keyword:`if`, :keyword:`while` 和 :keyword:`for` 语句用来实现传统的控制流程构造。 "
":keyword:`try` 语句为一组语句指定异常处理和/和清理代码,而 :keyword:`with` "
"语句允许在一个代码块周围执行初始化和终结化代码。 函数和类定义在语法上也属于复合语句。"
#: ../../reference/compound_stmts.rst:26
msgid ""
"A compound statement consists of one or more 'clauses.' A clause consists "
"of a header and a 'suite.' The clause headers of a particular compound "
"statement are all at the same indentation level. Each clause header begins "
"with a uniquely identifying keyword and ends with a colon. A suite is a "
"group of statements controlled by a clause. A suite can be one or more "
"semicolon-separated simple statements on the same line as the header, "
"following the header's colon, or it can be one or more indented statements "
"on subsequent lines. Only the latter form of a suite can contain nested "
"compound statements; the following is illegal, mostly because it wouldn't be"
" clear to which :keyword:`if` clause a following :keyword:`else` clause "
"would belong::"
msgstr ""
"一条复合语句由一个或多个‘子句’组成。 一个子句则包含一个句头和一个‘句体’。 特定复合语句的子句头都处于相同的缩进层级。 "
"每个子句头以一个作为唯一标识的关键字开始并以一个冒号结束。 子句体是由一个子句控制的一组语句。 "
"子句体可以是在子句头的冒号之后与其同处一行的一条或由分号分隔的多条简单语句,或者也可以是在其之后缩进的一行或多行语句。 "
"只有后一种形式的子句体才能包含嵌套的复合语句;以下形式是不合法的,这主要是因为无法分清某个后续的 :keyword:`else` 子句应该属于哪个 "
":keyword:`if` 子句::"
#: ../../reference/compound_stmts.rst:39
msgid ""
"Also note that the semicolon binds tighter than the colon in this context, "
"so that in the following example, either all or none of the :func:`print` "
"calls are executed::"
msgstr "还要注意的是在这种情形下分号的绑定比冒号更紧密,因此在以下示例中,所有 :func:`print` 调用或者都不执行,或者都执行::"
#: ../../reference/compound_stmts.rst:45
msgid "Summarizing:"
msgstr "总结:"
#: ../../reference/compound_stmts.rst:69
msgid ""
"Note that statements always end in a ``NEWLINE`` possibly followed by a "
"``DEDENT``. Also note that optional continuation clauses always begin with "
"a keyword that cannot start a statement, thus there are no ambiguities (the "
"'dangling :keyword:`else`' problem is solved in Python by requiring nested "
":keyword:`if` statements to be indented)."
msgstr ""
"请注意语句总是以 ``NEWLINE`` 结束,之后可能跟随一个 ``DEDENT``。 "
"还要注意可选的后续子句总是以一个不能作为语句开头的关键字作为开头,因此不会产生歧义(‘悬空的 :keyword:`else`’问题在 Python "
"中是通过要求嵌套的 :keyword:`if` 语句必须缩进来解决的)。"
#: ../../reference/compound_stmts.rst:75
msgid ""
"The formatting of the grammar rules in the following sections places each "
"clause on a separate line for clarity."
msgstr "为了保证清晰,以下各节中语法规则采用将每个子句都放在单独行中的格式。"
#: ../../reference/compound_stmts.rst:84
msgid "The :keyword:`!if` statement"
msgstr ":keyword:`!if` 语句"
#: ../../reference/compound_stmts.rst:92
msgid "The :keyword:`if` statement is used for conditional execution:"
msgstr ":keyword:`if` 语句用于有条件的执行:"
#: ../../reference/compound_stmts.rst:99
msgid ""
"It selects exactly one of the suites by evaluating the expressions one by "
"one until one is found to be true (see section :ref:`booleans` for the "
"definition of true and false); then that suite is executed (and no other "
"part of the :keyword:`if` statement is executed or evaluated). If all "
"expressions are false, the suite of the :keyword:`else` clause, if present, "
"is executed."
msgstr ""
"它通过对表达式逐个求值直至找到一个真值(请参阅 :ref:`booleans` "
"了解真值与假值的定义)在子句体中选择唯一匹配的一个;然后执行该子句体(而且 :keyword:`if` 语句的其他部分不会被执行或求值)。 "
"如果所有表达式均为假值,则如果 :keyword:`else` 子句体如果存在就会被执行。"
#: ../../reference/compound_stmts.rst:109
msgid "The :keyword:`!while` statement"
msgstr ":keyword:`!while` 语句"
#: ../../reference/compound_stmts.rst:117
msgid ""
"The :keyword:`while` statement is used for repeated execution as long as an "
"expression is true:"
msgstr ":keyword:`while` 语句用于在表达式保持为真的情况下重复地执行:"
#: ../../reference/compound_stmts.rst:124
msgid ""
"This repeatedly tests the expression and, if it is true, executes the first "
"suite; if the expression is false (which may be the first time it is tested)"
" the suite of the :keyword:`!else` clause, if present, is executed and the "
"loop terminates."
msgstr ""
"这将重复地检验表达式,并且如果其值为真就执行第一个子句体;如果表达式值为假(这可能在第一次检验时就发生)则如果 :keyword:`!else` "
"子句体存在就会被执行并终止循环。"
#: ../../reference/compound_stmts.rst:133
msgid ""
"A :keyword:`break` statement executed in the first suite terminates the loop"
" without executing the :keyword:`!else` clause's suite. A "
":keyword:`continue` statement executed in the first suite skips the rest of "
"the suite and goes back to testing the expression."
msgstr ""
"第一个子句体中的 :keyword:`break` 语句在执行时将终止循环且不执行 :keyword:`!else` 子句体。 第一个子句体中的 "
":keyword:`continue` 语句在执行时将跳过子句体中的剩余部分并返回检验表达式。"
#: ../../reference/compound_stmts.rst:142
msgid "The :keyword:`!for` statement"
msgstr ":keyword:`!for` 语句"
#: ../../reference/compound_stmts.rst:153
msgid ""
"The :keyword:`for` statement is used to iterate over the elements of a "
"sequence (such as a string, tuple or list) or other iterable object:"
msgstr ":keyword:`for` 语句用于对序列(例如字符串、元组或列表)或其他可迭代对象中的元素进行迭代:"
#: ../../reference/compound_stmts.rst:160
msgid ""
"The ``starred_list`` expression is evaluated once; it should yield an "
":term:`iterable` object. An :term:`iterator` is created for that iterable. "
"The first item provided by the iterator is then assigned to the target list "
"using the standard rules for assignments (see :ref:`assignment`), and the "
"suite is executed. This repeats for each item provided by the iterator. "
"When the iterator is exhausted, the suite in the :keyword:`!else` clause, if"
" present, is executed, and the loop terminates."
msgstr ""
"``starred_list`` 表达式会被求值一次;它应当产生一个 :term:`iterable` 对象。 将针对该可迭代对象创建一个 "
":term:`iterator`。 随后该迭代器所提供的第一个条目将使用标准的赋值规则被赋值给目标列表 (参见 "
":ref:`assignment`),而代码块将被执行。 此过程将针对该迭代器所提供每个条目重复进行。 当迭代器被耗尽时,如果存在 "
":keyword:`!else` 子句中的代码块,则它将被执行,并终结循环。"
#: ../../reference/compound_stmts.rst:173
msgid ""
"A :keyword:`break` statement executed in the first suite terminates the loop"
" without executing the :keyword:`!else` clause's suite. A "
":keyword:`continue` statement executed in the first suite skips the rest of "
"the suite and continues with the next item, or with the :keyword:`!else` "
"clause if there is no next item."
msgstr ""
"第一个子句体中的 :keyword:`break` 语句在执行时将终止循环且不执行 :keyword:`!else` 子句体。 第一个子句体中的 "
":keyword:`continue` 语句在执行时将跳过子句体中的剩余部分并转往下一项继续执行,或者在没有下一项时转往 "
":keyword:`!else` 子句执行。"
#: ../../reference/compound_stmts.rst:179
msgid ""
"The for-loop makes assignments to the variables in the target list. This "
"overwrites all previous assignments to those variables including those made "
"in the suite of the for-loop::"
msgstr "for 循环会对目标列表中的变量进行赋值。 这将覆盖之前对这些变量的所有赋值,包括在 for 循环体中的赋值::"
#: ../../reference/compound_stmts.rst:193
msgid ""
"Names in the target list are not deleted when the loop is finished, but if "
"the sequence is empty, they will not have been assigned to at all by the "
"loop. Hint: the built-in type :func:`range` represents immutable arithmetic"
" sequences of integers. For instance, iterating ``range(3)`` successively "
"yields 0, 1, and then 2."
msgstr ""
"目标列表中的名称在循环结束时不会被删除,但是如果序列为空,则它们将根本不会被循环所赋值。 提示:内置类型 :func:`range` "
"代表由整数组成的不可变算数序列。 例如,迭代 ``range(3)`` 将依次产生 0, 1 和 2。"
#: ../../reference/compound_stmts.rst:198
msgid "Starred elements are now allowed in the expression list."
msgstr "现在允许在表达式列表中使用带星号的元素。"
#: ../../reference/compound_stmts.rst:205
msgid "The :keyword:`!try` statement"
msgstr ":keyword:`!try` 语句"
#: ../../reference/compound_stmts.rst:215
msgid ""
"The :keyword:`!try` statement specifies exception handlers and/or cleanup "
"code for a group of statements:"
msgstr ":keyword:`!try` 语句可为一组语句指定异常处理器和/或清理代码:"
#: ../../reference/compound_stmts.rst:231
msgid ""
"Additional information on exceptions can be found in section "
":ref:`exceptions`, and information on using the :keyword:`raise` statement "
"to generate exceptions may be found in section :ref:`raise`."
msgstr ""
"有关异常的更多信息可以在 :ref:`exceptions` 一节找到,有关使用 :keyword:`raise` 语句生成异常的信息可以在 "
":ref:`raise` 一节找到。"
#: ../../reference/compound_stmts.rst:239
msgid ":keyword:`!except` clause"
msgstr ":keyword:`!except` 子句"
#: ../../reference/compound_stmts.rst:241
msgid ""
"The :keyword:`!except` clause(s) specify one or more exception handlers. "
"When no exception occurs in the :keyword:`try` clause, no exception handler "
"is executed. When an exception occurs in the :keyword:`!try` suite, a search"
" for an exception handler is started. This search inspects the "
":keyword:`!except` clauses in turn until one is found that matches the "
"exception. An expression-less :keyword:`!except` clause, if present, must be"
" last; it matches any exception. For an :keyword:`!except` clause with an "
"expression, that expression is evaluated, and the clause matches the "
"exception if the resulting object is \"compatible\" with the exception. An "
"object is compatible with an exception if the object is the class or a "
":term:`non-virtual base class <abstract base class>` of the exception "
"object, or a tuple containing an item that is the class or a non-virtual "
"base class of the exception object."
msgstr ""
":keyword:`!except` 子句指定一个或多个异常处理器。 当 :keyword:`try` "
"子句中无异常发生时,将不会有任何异常处理器被执行。 当 :keyword:`!try` 子句代码块中发生异常时,将启动对异常处理器的搜索。 "
"此搜索会逐一检查 :keyword:`!except` 子句直至找到与该异常相匹配的子句为止。 如果存在无表达式的 :keyword:`!except`"
" 子句,则它必须是最后一个;它将匹配任何异常。 对于带有表达式的 :keyword:`!except` "
"子句,该表达式会被求值,如果结果对象与发生的异常“兼容”则该子句将匹配该异常。 如果一个对象是该异常对象所属的类或是其 :term:`非虚拟基类 "
"<abstract base class>`,或者是包含异常对象的类或该异常对象的非虚拟基类条目的元组,则此对象就是与该异常兼容的。"
#: ../../reference/compound_stmts.rst:256
msgid ""
"If no :keyword:`!except` clause matches the exception, the search for an "
"exception handler continues in the surrounding code and on the invocation "
"stack. [#]_"
msgstr "如果没有 :keyword:`!except` 子句与异常相匹配,则会在周边代码和唤起栈上继续搜索异常处理器。 [#]_"
#: ../../reference/compound_stmts.rst:260
msgid ""
"If the evaluation of an expression in the header of an :keyword:`!except` "
"clause raises an exception, the original search for a handler is canceled "
"and a search starts for the new exception in the surrounding code and on the"
" call stack (it is treated as if the entire :keyword:`try` statement raised "
"the exception)."
msgstr ""
"如果在对 :keyword:`!except` "
"子句头部的表达式求值时引发了异常,则对处理器的原始搜索会被取消并在周边代码和调用栈上启动对新异常的搜索(它会被视作是整个 :keyword:`try` "
"语句所引发的异常)。"
#: ../../reference/compound_stmts.rst:268
msgid ""
"When a matching :keyword:`!except` clause is found, the exception is "
"assigned to the target specified after the :keyword:`!as` keyword in that "
":keyword:`!except` clause, if present, and the :keyword:`!except` clause's "
"suite is executed. All :keyword:`!except` clauses must have an executable "
"block. When the end of this block is reached, execution continues normally "
"after the entire :keyword:`try` statement. (This means that if two nested "
"handlers exist for the same exception, and the exception occurs in the "
":keyword:`!try` clause of the inner handler, the outer handler will not "
"handle the exception.)"
msgstr ""
"当代到一个匹配的 :keyword:`!except` 子句时,异常将被赋值给该 :keyword:`!except` 子句在 "
":keyword:`!as` 关键字之后指定的目标,如果存在此关键字的话,并且该 :keyword:`!except` 子句的代码块将被执行。 所有 "
":keyword:`!except` 子句都必须有可执行的代码块。 当到达此类代码块的末尾时,通常会转到整个 :keyword:`try` "
"语句之后继续执行。 (这意味着如果对同一异常存在两个嵌套的处理器,并且异常发生在内层处理器的 :keyword:`!try` "
"子句中,则外层处理器将不会处理该异常。)"
#: ../../reference/compound_stmts.rst:279
msgid ""
"When an exception has been assigned using ``as target``, it is cleared at "
"the end of the :keyword:`!except` clause. This is as if ::"
msgstr "当使用 ``as target`` 来为异常赋值时,它将在 :keyword:`!except` 子句结束时被清除。 这就相当于 ::"
#: ../../reference/compound_stmts.rst:285
msgid "was translated to ::"
msgstr "被转写为 ::"
#: ../../reference/compound_stmts.rst:293
msgid ""
"This means the exception must be assigned to a different name to be able to "
"refer to it after the :keyword:`!except` clause. Exceptions are cleared "
"because with the traceback attached to them, they form a reference cycle "
"with the stack frame, keeping all locals in that frame alive until the next "
"garbage collection occurs."
msgstr ""
"这意味着异常必须被赋值给一个不同的名称才能在 :keyword:`!except` 子句之后引用它。 "
"异常会被清除是因为在附加了回溯信息的情况下它们会形成栈帧的循环引用,使得帧中的所有局部变量保持存活直到发生下一次垃圾回收。"
#: ../../reference/compound_stmts.rst:303
msgid ""
"Before an :keyword:`!except` clause's suite is executed, the exception is "
"stored in the :mod:`sys` module, where it can be accessed from within the "
"body of the :keyword:`!except` clause by calling :func:`sys.exception`. When"
" leaving an exception handler, the exception stored in the :mod:`sys` module"
" is reset to its previous value::"
msgstr ""
"在 :keyword:`!except` 子句的代码块被执行之前,异常将保存在 :mod:`sys` 模块中,在那里它可以从 "
":keyword:`!except` 子句的语句体内部通过 :func:`sys.exception` 被访问。 当离开一个异常处理器时,保存在 "
":mod:`sys` 模块中的异常将被重置为在此之前的值::"
#: ../../reference/compound_stmts.rst:334
msgid ":keyword:`!except*` clause"
msgstr ":keyword:`!except*` 子句"
#: ../../reference/compound_stmts.rst:336
msgid ""
"The :keyword:`!except*` clause(s) are used for handling "
":exc:`ExceptionGroup`\\s. The exception type for matching is interpreted as "
"in the case of :keyword:`except`, but in the case of exception groups we can"
" have partial matches when the type matches some of the exceptions in the "
"group. This means that multiple :keyword:`!except*` clauses can execute, "
"each handling part of the exception group. Each clause executes at most once"
" and handles an exception group of all matching exceptions. Each exception "
"in the group is handled by at most one :keyword:`!except*` clause, the first"
" that matches it. ::"
msgstr ""
":keyword:`!except*` 子句被用来处理 :exc:`ExceptionGroup`。 要匹配的异常类型将按与 "
":keyword:`except` 中的相同的方式来解读,但在使用异常组的情况下当类型与组内的某些异常相匹配时我们可以有部分匹配。 这意味着有多个 "
":keyword:`!except*` 子句可被执行,各自处理异常组的一部分。 每个子句最多执行一次并处理所有匹配异常中的一个异常组。 "
"组内的每个异常将至多由一个 :keyword:`!except*` 子句来处理,即第一个与其匹配的子句。 ::"
#: ../../reference/compound_stmts.rst:364
msgid ""
"Any remaining exceptions that were not handled by any :keyword:`!except*` "
"clause are re-raised at the end, combined into an exception group along with"
" all exceptions that were raised from within :keyword:`!except*` clauses."
msgstr ""
"任何未被 :keyword:`!except*` 子句处理的剩余异常都会在最后被重新引发,并与 :keyword:`!except*` "
"子句引发的所有异常合并为一个异常组。"
#: ../../reference/compound_stmts.rst:368
msgid ""
"From version 3.11.4, when the entire :exc:`ExceptionGroup` is handled and "
"only one exception is raised from an :keyword:`!except*` clause, this "
"exception is no longer wrapped to form a new :exc:`ExceptionGroup`."
msgstr ""
"从 3.11.4 版开始,在处理整个 :exc:`ExceptionGroup` 时,如果只从 :keyword:`!except*` "
"子句引发一个异常,则不再对该异常进行包装以形成新的 :exc:`ExceptionGroup`。"
#: ../../reference/compound_stmts.rst:372
msgid ""
"If the raised exception is not an exception group and its type matches one "
"of the :keyword:`!except*` clauses, it is caught and wrapped by an exception"
" group with an empty message string. ::"
msgstr ""
"如果被引发的异常不是一个异常组并且其类型与某个 :keyword:`!except*` 子句相匹配,它将被捕获并由附带空消息字符串的异常组来包装。 ::"
#: ../../reference/compound_stmts.rst:383
msgid ""
"An :keyword:`!except*` clause must have a matching type, and this type "
"cannot be a subclass of :exc:`BaseExceptionGroup`. It is not possible to mix"
" :keyword:`except` and :keyword:`!except*` in the same :keyword:`try`. "
":keyword:`break`, :keyword:`continue` and :keyword:`return` cannot appear in"
" an :keyword:`!except*` clause."
msgstr ""
"一个 :keyword:`!except*` 子句必须有一个匹配的类型,并且此类型不能是 :exc:`BaseExceptionGroup` 的子类。 "
"不可以将 :keyword:`except` 和 :keyword:`!except*` 在同一个 :keyword:`try` 中混用。 "
":keyword:`break`, :keyword:`continue` 和 :keyword:`return` 不可出现在 "
":keyword:`!except*` 子句中。"
#: ../../reference/compound_stmts.rst:400
msgid ":keyword:`!else` clause"
msgstr ":keyword:`!else` 子句"
#: ../../reference/compound_stmts.rst:402
msgid ""
"The optional :keyword:`!else` clause is executed if the control flow leaves "
"the :keyword:`try` suite, no exception was raised, and no :keyword:`return`,"
" :keyword:`continue`, or :keyword:`break` statement was executed. "
"Exceptions in the :keyword:`!else` clause are not handled by the preceding "
":keyword:`except` clauses."
msgstr ""
"如果控制流离开 :keyword:`try` 子句体时没有引发异常,并且没有执行 :keyword:`return`, "
":keyword:`continue` 或 :keyword:`break` 语句,可选的 :keyword:`!else` 子句将被执行。 "
":keyword:`!else` 语句中的异常不会由之前的 :keyword:`except` 子句处理。"
#: ../../reference/compound_stmts.rst:414
msgid ":keyword:`!finally` clause"
msgstr ":keyword:`!finally` 子句"
#: ../../reference/compound_stmts.rst:416
msgid ""
"If :keyword:`!finally` is present, it specifies a 'cleanup' handler. The "
":keyword:`try` clause is executed, including any :keyword:`except` and "
":keyword:`else` clauses. If an exception occurs in any of the clauses and "
"is not handled, the exception is temporarily saved. The :keyword:`!finally` "
"clause is executed. If there is a saved exception it is re-raised at the "
"end of the :keyword:`!finally` clause. If the :keyword:`!finally` clause "
"raises another exception, the saved exception is set as the context of the "
"new exception. If the :keyword:`!finally` clause executes a "
":keyword:`return`, :keyword:`break` or :keyword:`continue` statement, the "
"saved exception is discarded::"
msgstr ""
"如果存在 :keyword:`!finally`,它将指定一个‘清理’处理器。 :keyword:`try` 子句会被执行,包括任何 "
":keyword:`except` 和 :keyword:`else` 子句。 如果在这些子句中发生任何未处理的异常,该异常会被临时保存。 "
":keyword:`!finally` 子句将被执行。 如果存在被保存的异常,它会在 :keyword:`!finally` 子句的末尾被重新引发。 "
"如果 :keyword:`!finally` 子句引发了另一个异常,被保存的异常会被设为新异常的上下文。 如果 :keyword:`!finally` "
"子句执行了 :keyword:`return`, :keyword:`break` 或 :keyword:`continue` "
"语句,则被保存的异常会被丢弃::"
#: ../../reference/compound_stmts.rst:435
msgid ""
"The exception information is not available to the program during execution "
"of the :keyword:`!finally` clause."
msgstr "在 :keyword:`!finally` 子句执行期间程序将不能获取到异常信息。"
#: ../../reference/compound_stmts.rst:443
msgid ""
"When a :keyword:`return`, :keyword:`break` or :keyword:`continue` statement "
"is executed in the :keyword:`try` suite of a :keyword:`!try`...\\ "
":keyword:`!finally` statement, the :keyword:`!finally` clause is also "
"executed 'on the way out.'"
msgstr ""
"当 :keyword:`return`, :keyword:`break` 或 :keyword:`continue` 语句在一个 "
":keyword:`!try`...\\ :keyword:`!finally` 语句的 :keyword:`try` "
"子句的代码块中被执行时,:keyword:`!finally` 子句也会在‘离开时’被执行。"
#: ../../reference/compound_stmts.rst:447
msgid ""
"The return value of a function is determined by the last :keyword:`return` "
"statement executed. Since the :keyword:`!finally` clause always executes, a"
" :keyword:`!return` statement executed in the :keyword:`!finally` clause "
"will always be the last one executed::"
msgstr ""
"函数的返回值是由最后被执行的 :keyword:`return` 语句来决定的。 由于 :keyword:`!finally` 子句总是会被执行,因此在"
" :keyword:`!finally` 子句中被执行的 :keyword:`!return` 语句将总是最后被执行的::"
#: ../../reference/compound_stmts.rst:461
msgid ""
"Prior to Python 3.8, a :keyword:`continue` statement was illegal in the "
":keyword:`!finally` clause due to a problem with the implementation."
msgstr ""
"在 Python 3.8 之前,:keyword:`continue` 语句不允许在 :keyword:`!finally` "
"子句中使用,这是因为具体实现中存在一个问题。"
#: ../../reference/compound_stmts.rst:470
msgid "The :keyword:`!with` statement"
msgstr ":keyword:`!with` 语句"
#: ../../reference/compound_stmts.rst:479
msgid ""
"The :keyword:`with` statement is used to wrap the execution of a block with "
"methods defined by a context manager (see section :ref:`context-managers`). "
"This allows common :keyword:`try`...\\ :keyword:`except`...\\ "
":keyword:`finally` usage patterns to be encapsulated for convenient reuse."
msgstr ""
":keyword:`with` 语句用于包装带有使用上下文管理器 (参见 :ref:`context-managers` 一节) "
"定义的方法的代码块的执行。 这允许对普通的 :keyword:`try`...\\ :keyword:`except`...\\ "
":keyword:`finally` 使用模式进行封装以方便地重用。"
#: ../../reference/compound_stmts.rst:489
msgid ""
"The execution of the :keyword:`with` statement with one \"item\" proceeds as"
" follows:"
msgstr "带有一个“项目”的 :keyword:`with` 语句的执行过程如下:"
#: ../../reference/compound_stmts.rst:491
msgid ""
"The context expression (the expression given in the :token:`~python-"
"grammar:with_item`) is evaluated to obtain a context manager."
msgstr "对上下文表达式(在 :token:`~python-grammar:with_item` 中给出的表达式)进行求值来获得上下文管理器。"
#: ../../reference/compound_stmts.rst:494
msgid ""
"The context manager's :meth:`~object.__enter__` is loaded for later use."
msgstr "载入上下文管理器的 :meth:`~object.__enter__` 以便后续使用。"
#: ../../reference/compound_stmts.rst:496
msgid ""
"The context manager's :meth:`~object.__exit__` is loaded for later use."
msgstr "载入上下文管理器的 :meth:`~object.__exit__` 以便后续使用。"
#: ../../reference/compound_stmts.rst:498
msgid "The context manager's :meth:`~object.__enter__` method is invoked."
msgstr "唤起上下文管理器的 :meth:`~object.__enter__` 方法。"
#: ../../reference/compound_stmts.rst:500
msgid ""
"If a target was included in the :keyword:`with` statement, the return value "
"from :meth:`~object.__enter__` is assigned to it."
msgstr "如果一个目标被包括在 :keyword:`with` 语句中,则把它赋值为 :meth:`~object.__enter__` 的返回值。"
#: ../../reference/compound_stmts.rst:505
msgid ""
"The :keyword:`with` statement guarantees that if the "
":meth:`~object.__enter__` method returns without an error, then "
":meth:`~object.__exit__` will always be called. Thus, if an error occurs "
"during the assignment to the target list, it will be treated the same as an "
"error occurring within the suite would be. See step 7 below."
msgstr ""
":keyword:`with` 语句会保证如果 :meth:`~object.__enter__` 方法未发生错误地返回,则 "
":meth:`~object.__exit__` 将一定被调用。 因此,如果在对目标列表赋值期间发生错误,它将被当作在语句体内部发生的错误来处理。 "
"参见下面的第 7 步。"
#: ../../reference/compound_stmts.rst:511
msgid "The suite is executed."
msgstr "执行语句体。"
#: ../../reference/compound_stmts.rst:513
msgid ""
"The context manager's :meth:`~object.__exit__` method is invoked. If an "
"exception caused the suite to be exited, its type, value, and traceback are "
"passed as arguments to :meth:`~object.__exit__`. Otherwise, three "
":const:`None` arguments are supplied."
msgstr ""
"唤起上下文管理器的 :meth:`~object.__exit__` 方法。 如果语句体的退出是由异常导致的,则其类型、值和回溯信息将被作为参数传递给 "
":meth:`~object.__exit__`。 否则的话,将提供三个 :const:`None` 参数。"
#: ../../reference/compound_stmts.rst:518
msgid ""
"If the suite was exited due to an exception, and the return value from the "
":meth:`~object.__exit__` method was false, the exception is reraised. If "
"the return value was true, the exception is suppressed, and execution "
"continues with the statement following the :keyword:`with` statement."
msgstr ""
"如果语句体的退出是由异常导致的,并且来自 :meth:`~object.__exit__` 方法的返回值为假,则该异常会被重新引发。 "
"如果返回值为真,则该异常会被抑制,并会继续执行 :keyword:`with` 语句之后的语句。"
#: ../../reference/compound_stmts.rst:523
msgid ""
"If the suite was exited for any reason other than an exception, the return "
"value from :meth:`~object.__exit__` is ignored, and execution proceeds at "
"the normal location for the kind of exit that was taken."
msgstr ""
"如果语句体由于异常以外的任何原因退出,则来自 :meth:`~object.__exit__` 的返回值会被忽略,并会在该类退出正常的发生位置继续执行。"
#: ../../reference/compound_stmts.rst:527
#: ../../reference/compound_stmts.rst:1523
#: ../../reference/compound_stmts.rst:1564
msgid "The following code::"
msgstr "以下代码::"
#: ../../reference/compound_stmts.rst:532
#: ../../reference/compound_stmts.rst:557
#: ../../reference/compound_stmts.rst:1569
msgid "is semantically equivalent to::"
msgstr "在语义上等价于::"
#: ../../reference/compound_stmts.rst:551
msgid ""
"With more than one item, the context managers are processed as if multiple "
":keyword:`with` statements were nested::"
msgstr "如果有多个项目,则会视作存在多个 :keyword:`with` 语句嵌套来处理多个上下文管理器::"
#: ../../reference/compound_stmts.rst:563
msgid ""
"You can also write multi-item context managers in multiple lines if the "
"items are surrounded by parentheses. For example::"
msgstr "也可以用圆括号包围的多行形式的多项目上下文管理器。例如::"
#: ../../reference/compound_stmts.rst:572
msgid "Support for multiple context expressions."
msgstr "支持多个上下文表达式。"
#: ../../reference/compound_stmts.rst:575
msgid ""
"Support for using grouping parentheses to break the statement in multiple "
"lines."
msgstr " 支持用圆括号将语句分成多行。"
#: ../../reference/compound_stmts.rst:581
msgid ":pep:`343` - The \"with\" statement"
msgstr ":pep:`343` - \"with\" 语句"
#: ../../reference/compound_stmts.rst:581
msgid ""
"The specification, background, and examples for the Python :keyword:`with` "
"statement."
msgstr "Python :keyword:`with` 语句的规范描述、背景和示例。"
#: ../../reference/compound_stmts.rst:587
msgid "The :keyword:`!match` statement"
msgstr ":keyword:`!match` 语句"
#: ../../reference/compound_stmts.rst:601
msgid "The match statement is used for pattern matching. Syntax:"
msgstr "匹配语句用于进行模式匹配。语法如下:"
#: ../../reference/compound_stmts.rst:610
msgid ""
"This section uses single quotes to denote :ref:`soft keywords <soft-"
"keywords>`."
msgstr "本节使用单引号来表示 :ref:`软关键字 <soft-keywords>`。"
#: ../../reference/compound_stmts.rst:613
msgid ""
"Pattern matching takes a pattern as input (following ``case``) and a subject"
" value (following ``match``). The pattern (which may contain subpatterns) "
"is matched against the subject value. The outcomes are:"
msgstr ""
"模式匹配接受一个模式作为输入(跟在 ``case`` 后),一个目标值(跟在 ``match`` "
"后)。该模式(可能包含子模式)将与目标值进行匹配。输出是:"
#: ../../reference/compound_stmts.rst:617
msgid "A match success or failure (also termed a pattern success or failure)."
msgstr "匹配成功或失败(也被称为模式成功或失败)。"
#: ../../reference/compound_stmts.rst:619
msgid ""
"Possible binding of matched values to a name. The prerequisites for this "
"are further discussed below."
msgstr "可能将匹配的值绑定到一个名字上。 这方面的先决条件将在下面进一步讨论。"
#: ../../reference/compound_stmts.rst:622
msgid ""
"The ``match`` and ``case`` keywords are :ref:`soft keywords <soft-"
"keywords>`."
msgstr "关键字 ``match`` 和 ``case`` 是 :ref:`soft keywords <soft-keywords>` 。"
#: ../../reference/compound_stmts.rst:626
#: ../../reference/compound_stmts.rst:1183
msgid ":pep:`634` -- Structural Pattern Matching: Specification"
msgstr ":pep:`634` —— 结构化模式匹配:规范"
#: ../../reference/compound_stmts.rst:627
#: ../../reference/compound_stmts.rst:1184
msgid ":pep:`636` -- Structural Pattern Matching: Tutorial"
msgstr ":pep:`636` —— 结构化模式匹配:教程"
#: ../../reference/compound_stmts.rst:631
msgid "Overview"
msgstr "概述"
#: ../../reference/compound_stmts.rst:633
msgid "Here's an overview of the logical flow of a match statement:"
msgstr "匹配语句逻辑流程的概述如下:"
#: ../../reference/compound_stmts.rst:636
msgid ""
"The subject expression ``subject_expr`` is evaluated and a resulting subject"
" value obtained. If the subject expression contains a comma, a tuple is "
"constructed using :ref:`the standard rules <typesseq-tuple>`."
msgstr ""
"对目标表达式 ``subject_expr`` 求值后将结果作为匹配用的目标值。 如果目标表达式包含逗号,则使用 :ref:`the standard "
"rules <typesseq-tuple>` 构建一个元组。"
#: ../../reference/compound_stmts.rst:640
msgid ""
"Each pattern in a ``case_block`` is attempted to match with the subject "
"value. The specific rules for success or failure are described below. The "
"match attempt can also bind some or all of the standalone names within the "
"pattern. The precise pattern binding rules vary per pattern type and are "
"specified below. **Name bindings made during a successful pattern match "
"outlive the executed block and can be used after the match statement**."
msgstr ""
"目标值将依次与 ``case_block`` "
"中的每个模式进行匹配。匹配成功或失败的具体规则在下面描述。匹配尝试也可以与模式中的一些或所有的独立名称绑定。准确的模式绑定规则因模式类型而异,具体规定见下文。**成功的模式匹配过程中产生的名称绑定将超越所执行的块的范围,可以在匹配语句之后使用**。"
#: ../../reference/compound_stmts.rst:649
msgid ""
"During failed pattern matches, some subpatterns may succeed. Do not rely on"
" bindings being made for a failed match. Conversely, do not rely on "
"variables remaining unchanged after a failed match. The exact behavior is "
"dependent on implementation and may vary. This is an intentional decision "
"made to allow different implementations to add optimizations."
msgstr ""
"在模式匹配失败时,一些子模式可能会成功。 不要依赖于失败匹配进行的绑定。 反过来说,不要认为变量在匹配失败后保持不变。 "
"确切的行为取决于实现,可能会有所不同。 这是一个有意的决定,允许不同的实现添加优化。"
#: ../../reference/compound_stmts.rst:656
msgid ""
"If the pattern succeeds, the corresponding guard (if present) is evaluated. "
"In this case all name bindings are guaranteed to have happened."
msgstr "如果该模式匹配成功,并且完成了对相应的约束项(如果存在)的求值。在这种情况下,保证完成所有的名称绑定。"
#: ../../reference/compound_stmts.rst:659
msgid ""
"If the guard evaluates as true or is missing, the ``block`` inside "
"``case_block`` is executed."
msgstr "如果约束项求值为真或缺失,执行 ``case_block`` 中的 ``block`` 。"
#: ../../reference/compound_stmts.rst:662
msgid "Otherwise, the next ``case_block`` is attempted as described above."
msgstr "否则,将按照上述方法尝试下一个 ``case_block`` 。"
#: ../../reference/compound_stmts.rst:664
msgid "If there are no further case blocks, the match statement is completed."
msgstr "如果没有进一步的 case 块,匹配语句终止。"
#: ../../reference/compound_stmts.rst:668
msgid ""
"Users should generally never rely on a pattern being evaluated. Depending "
"on implementation, the interpreter may cache values or use other "
"optimizations which skip repeated evaluations."
msgstr "用户一般不应依赖正在求值的模式。 根据不同的实现方式,解释器可能会缓存数值或使用其他优化方法来避免重复求值。"
#: ../../reference/compound_stmts.rst:672
msgid "A sample match statement::"
msgstr "匹配语句示例::"
#: ../../reference/compound_stmts.rst:688
msgid ""
"In this case, ``if flag`` is a guard. Read more about that in the next "
"section."
msgstr "在这个示例中,``if flag`` 是约束项。请阅读下一节以了解更多相关内容。"
#: ../../reference/compound_stmts.rst:691
msgid "Guards"
msgstr "约束项"
#: ../../reference/compound_stmts.rst:698
msgid ""
"A ``guard`` (which is part of the ``case``) must succeed for code inside the"
" ``case`` block to execute. It takes the form: :keyword:`if` followed by an"
" expression."
msgstr ""
"``guard`` (它是 ``case`` 的一部分) 必须成立才能让 ``case`` 语句块中的代码被执行。 它所采用的形式为: "
":keyword:`if` 之后跟一个表达式。"
#: ../../reference/compound_stmts.rst:703
msgid "The logical flow of a ``case`` block with a ``guard`` follows:"
msgstr "拥有 ``guard`` 的 ``case`` 块的逻辑流程如下:"
#: ../../reference/compound_stmts.rst:705
msgid ""
"Check that the pattern in the ``case`` block succeeded. If the pattern "
"failed, the ``guard`` is not evaluated and the next ``case`` block is "
"checked."
msgstr ""
"检查 ``case`` 块中的模式是否匹配成功。如果该模式匹配失败,则不对 ``guard`` 进行求值,检查下一个 ``case`` 块。"
#: ../../reference/compound_stmts.rst:709
msgid "If the pattern succeeded, evaluate the ``guard``."
msgstr "如果该模式匹配成功,对 ``guard`` 求值。"
#: ../../reference/compound_stmts.rst:711
msgid ""
"If the ``guard`` condition evaluates as true, the case block is selected."
msgstr "如果 ``guard`` 求值为真,则选用该 case 块。"
#: ../../reference/compound_stmts.rst:714
msgid ""
"If the ``guard`` condition evaluates as false, the case block is not "
"selected."
msgstr "如果 ``guard`` 求值为假,则不选用该 case 块。"
#: ../../reference/compound_stmts.rst:717
msgid ""
"If the ``guard`` raises an exception during evaluation, the exception "
"bubbles up."
msgstr "如果在对 ``guard`` 求值过程中引发了异常,则异常将被抛出。"
#: ../../reference/compound_stmts.rst:720
msgid ""
"Guards are allowed to have side effects as they are expressions. Guard "
"evaluation must proceed from the first to the last case block, one at a "
"time, skipping case blocks whose pattern(s) don't all succeed. (I.e., guard "
"evaluation must happen in order.) Guard evaluation must stop once a case "
"block is selected."
msgstr ""
"允许约束项产生副作用,因为他们是表达式。约束项求值必须从第一个 case 块到最后一个 case 块依次逐个进行,模式匹配失败的 case "
"块将被跳过。(也就是说,约束项求值必须按顺序进行。)一旦选用了一个 case 块,约束项求值必须由此终止。"
#: ../../reference/compound_stmts.rst:730
msgid "Irrefutable Case Blocks"
msgstr "必定匹配的 case 块"
#: ../../reference/compound_stmts.rst:734
msgid ""
"An irrefutable case block is a match-all case block. A match statement may "
"have at most one irrefutable case block, and it must be last."
msgstr "必定匹配的 case 块是能匹配所有情况的 case 块。一个匹配语句最多可以有一个必定匹配的 case 块,而且必须是最后一个。"
#: ../../reference/compound_stmts.rst:737
msgid ""
"A case block is considered irrefutable if it has no guard and its pattern is"
" irrefutable. A pattern is considered irrefutable if we can prove from its "
"syntax alone that it will always succeed. Only the following patterns are "
"irrefutable:"
msgstr ""
"如果一个 case 块没有约束项,并且其模式是必定匹配的,那么它就被认为是必定匹配的。 "
"如果我们可以仅从语法上证明一个模式总是能匹配成功,那么这个模式就被认为是必定匹配的。 只有以下模式是必定匹配的:"
#: ../../reference/compound_stmts.rst:742
msgid ":ref:`as-patterns` whose left-hand side is irrefutable"
msgstr "左侧模式是必定匹配的 :ref:`as-patterns`"
#: ../../reference/compound_stmts.rst:744
msgid ":ref:`or-patterns` containing at least one irrefutable pattern"
msgstr "包含至少一个必定匹配模式的 :ref:`or-patterns`"
#: ../../reference/compound_stmts.rst:746
msgid ":ref:`capture-patterns`"
msgstr ":ref:`capture-patterns`"
#: ../../reference/compound_stmts.rst:748
msgid ":ref:`wildcard-patterns`"
msgstr ":ref:`wildcard-patterns`"
#: ../../reference/compound_stmts.rst:750
msgid "parenthesized irrefutable patterns"
msgstr "括号内的必定匹配模式"
#: ../../reference/compound_stmts.rst:754
msgid "Patterns"
msgstr "模式"
#: ../../reference/compound_stmts.rst:761
msgid "This section uses grammar notations beyond standard EBNF:"
msgstr "本节使用了超出标准 EBNF 的语法符号。"
#: ../../reference/compound_stmts.rst:763
msgid "the notation ``SEP.RULE+`` is shorthand for ``RULE (SEP RULE)*``"
msgstr "符号 ``SEP.RULE+`` 是 ``RULE (SEP RULE)*`` 的简写"
#: ../../reference/compound_stmts.rst:765
msgid "the notation ``!RULE`` is shorthand for a negative lookahead assertion"
msgstr "符号 ``!RULE`` 是前向否定断言的简写"
#: ../../reference/compound_stmts.rst:768
msgid "The top-level syntax for ``patterns`` is:"
msgstr "``patterns`` 的顶层语法是:"
#: ../../reference/compound_stmts.rst:782
msgid ""
"The descriptions below will include a description \"in simple terms\" of "
"what a pattern does for illustration purposes (credits to Raymond Hettinger "
"for a document that inspired most of the descriptions). Note that these "
"descriptions are purely for illustration purposes and **may not** reflect "
"the underlying implementation. Furthermore, they do not cover all valid "
"forms."
msgstr ""
"下面的描述将包括一个“简而言之”以描述模式的作用,便于说明问题(感谢 Raymond Hettinger "
"提供的一份文件,大部分的描述受其启发)。请注意,这些描述纯粹是为了说明问题,**可能不** 反映底层的实现。此外,它们并没有涵盖所有有效的形式。"
#: ../../reference/compound_stmts.rst:792
msgid "OR Patterns"
msgstr "或模式"
#: ../../reference/compound_stmts.rst:794
msgid ""
"An OR pattern is two or more patterns separated by vertical bars ``|``. "
"Syntax:"
msgstr "或模式是由竖杠 ``|`` 分隔的两个或更多的模式。语法:"
#: ../../reference/compound_stmts.rst:800
msgid ""
"Only the final subpattern may be :ref:`irrefutable <irrefutable_case>`, and "
"each subpattern must bind the same set of names to avoid ambiguity."
msgstr "只有最后的子模式可以是 :ref:`必定匹配的 <irrefutable_case>`,且每个子模式必须绑定相同的名字集以避免歧义。"
#: ../../reference/compound_stmts.rst:803
msgid ""
"An OR pattern matches each of its subpatterns in turn to the subject value, "
"until one succeeds. The OR pattern is then considered successful. "
"Otherwise, if none of the subpatterns succeed, the OR pattern fails."
msgstr ""
"或模式将目标值依次与其每个子模式尝试匹配,直到有一个匹配成功,然后该或模式被视作匹配成功。 否则,如果没有任何子模式匹配成功,则或模式匹配失败。"
#: ../../reference/compound_stmts.rst:807
msgid ""
"In simple terms, ``P1 | P2 | ...`` will try to match ``P1``, if it fails it "
"will try to match ``P2``, succeeding immediately if any succeeds, failing "
"otherwise."
msgstr ""
"简而言之,``P1 | P2 | ...`` 会首先尝试匹配 ``P1`` ,如果失败将接着尝试匹配 ``P2`` "
",如果出现成功的匹配则立即结束且模式匹配成功,否则模式匹配失败。"
#: ../../reference/compound_stmts.rst:813
msgid "AS Patterns"
msgstr "AS 模式"
#: ../../reference/compound_stmts.rst:815
msgid ""
"An AS pattern matches an OR pattern on the left of the :keyword:`as` keyword"
" against a subject. Syntax:"
msgstr "AS 模式将关键字 :keyword:`as` 左侧的或模式与目标值进行匹配。语法:"
#: ../../reference/compound_stmts.rst:821
msgid ""
"If the OR pattern fails, the AS pattern fails. Otherwise, the AS pattern "
"binds the subject to the name on the right of the as keyword and succeeds. "
"``capture_pattern`` cannot be a ``_``."
msgstr ""
"如果 OR 模式匹配失败,则 AS 模式也会失败。 在其他情况下,AS 模块会将目标与 as 关键字右边的名称绑定并匹配成功。 "
"``capture_pattern`` 不可为 ``_``。"
#: ../../reference/compound_stmts.rst:825
msgid ""
"In simple terms ``P as NAME`` will match with ``P``, and on success it will "
"set ``NAME = <subject>``."
msgstr "简而言之, ``P as NAME`` 将与 ``P`` 匹配,成功后将设置 ``NAME = <subject>`` 。"
#: ../../reference/compound_stmts.rst:832
msgid "Literal Patterns"
msgstr "字面值模式"
#: ../../reference/compound_stmts.rst:834
msgid ""
"A literal pattern corresponds to most :ref:`literals <literals>` in Python."
" Syntax:"
msgstr "字面值模式对应 Python 中的大多数 :ref:`字面值 <literals>`。 语法为:"
#: ../../reference/compound_stmts.rst:847
msgid ""
"The rule ``strings`` and the token ``NUMBER`` are defined in the "
":doc:`standard Python grammar <./grammar>`. Triple-quoted strings are "
"supported. Raw strings and byte strings are supported. :ref:`f-strings` "
"are not supported."
msgstr ""
"规则 ``strings`` 和标记 ``NUMBER`` 是在 :doc:`standard Python grammar <./grammar>` "
"中定义的。支持三引号的字符串。不支持原始字符串和字节字符串。也不支持 :ref:`f-strings` 。"
#: ../../reference/compound_stmts.rst:852
msgid ""
"The forms ``signed_number '+' NUMBER`` and ``signed_number '-' NUMBER`` are "
"for expressing :ref:`complex numbers <imaginary>`; they require a real "
"number on the left and an imaginary number on the right. E.g. ``3 + 4j``."
msgstr ""
"``signed_number '+' NUMBER`` 和 ``signed_number '-' NUMBER`` 形式是用于表示 :ref:`复数"
" <imaginary>`;它们要求左边是一个实数而右边是一个虚数。 例如 ``3 + 4j``。"
#: ../../reference/compound_stmts.rst:856
msgid ""
"In simple terms, ``LITERAL`` will succeed only if ``<subject> == LITERAL``. "
"For the singletons ``None``, ``True`` and ``False``, the :keyword:`is` "
"operator is used."
msgstr ""
"简而言之, ``LITERAL`` 只会在 ``<subject> == LITERAL`` 时匹配成功。对于单例 ``None`` 、 "
"``True`` 和 ``False`` ,会使用 :keyword:`is` 运算符。"
#: ../../reference/compound_stmts.rst:862
msgid "Capture Patterns"
msgstr "捕获模式"
#: ../../reference/compound_stmts.rst:864
msgid "A capture pattern binds the subject value to a name. Syntax:"
msgstr "捕获模式将目标值与一个名称绑定。语法:"
#: ../../reference/compound_stmts.rst:870
msgid ""
"A single underscore ``_`` is not a capture pattern (this is what ``!'_'`` "
"expresses). It is instead treated as a :token:`~python-"
"grammar:wildcard_pattern`."
msgstr ""
"单独的一个下划线 ``_`` 不是捕获模式( ``!'_'`` 表达的就是这个含义)。 它会被当作 :token:`~python-"
"grammar:wildcard_pattern` 。"
#: ../../reference/compound_stmts.rst:874
msgid ""
"In a given pattern, a given name can only be bound once. E.g. ``case x, x: "
"...`` is invalid while ``case [x] | x: ...`` is allowed."
msgstr ""
"在给定的模式中,一个名字只能被绑定一次。例如 ``case x, x: ...`` 时无效的,但 ``case [x] | x: ...`` "
"是被允许的。"
#: ../../reference/compound_stmts.rst:877
msgid ""
"Capture patterns always succeed. The binding follows scoping rules "
"established by the assignment expression operator in :pep:`572`; the name "
"becomes a local variable in the closest containing function scope unless "
"there's an applicable :keyword:`global` or :keyword:`nonlocal` statement."
msgstr ""
"捕获模式总是能匹配成功。绑定遵循 :pep:`572` 中赋值表达式运算符设立的作用域规则;名字在最接近的包含函数作用域内成为一个局部变量,除非有适用的"
" :keyword:`global` 或 :keyword:`nonlocal` 语句。"
#: ../../reference/compound_stmts.rst:882
msgid ""
"In simple terms ``NAME`` will always succeed and it will set ``NAME = "
"<subject>``."
msgstr "简而言之, ``NAME`` 总是会匹配成功且将设置 ``NAME = <subject>`` 。"
#: ../../reference/compound_stmts.rst:887
msgid "Wildcard Patterns"
msgstr "通配符模式"
#: ../../reference/compound_stmts.rst:889
msgid ""
"A wildcard pattern always succeeds (matches anything) and binds no name. "
"Syntax:"
msgstr "通配符模式总是会匹配成功(匹配任何内容)并且不绑定任何名称。语法:"
#: ../../reference/compound_stmts.rst:895
msgid ""
"``_`` is a :ref:`soft keyword <soft-keywords>` within any pattern, but only "