-
-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathargparse.po
More file actions
2136 lines (1846 loc) · 101 KB
/
argparse.po
File metadata and controls
2136 lines (1846 loc) · 101 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.9\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-22 21:56+0000\n"
"PO-Revision-Date: 2025-09-22 17:54+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"
#: ../../library/argparse.rst:2
msgid ""
":mod:`argparse` --- Parser for command-line options, arguments and sub-"
"commands"
msgstr ":mod:`argparse` --- 命令行选项、参数和子命令解析器"
#: ../../library/argparse.rst:12
msgid "**Source code:** :source:`Lib/argparse.py`"
msgstr "**源代码:** :source:`Lib/argparse.py`"
#: ../../library/argparse.rstNone
msgid "Tutorial"
msgstr "教程"
#: ../../library/argparse.rst:18
msgid ""
"This page contains the API reference information. For a more gentle "
"introduction to Python command-line parsing, have a look at the "
":ref:`argparse tutorial <argparse-tutorial>`."
msgstr ""
"此页面包含该 API 的参考信息。有关 Python 命令行解析更细致的介绍,请参阅 :ref:`argparse 教程 <argparse-"
"tutorial>`。"
#: ../../library/argparse.rst:22
msgid ""
"The :mod:`argparse` module makes it easy to write user-friendly command-line"
" interfaces. The program defines what arguments it requires, and "
":mod:`argparse` will figure out how to parse those out of :data:`sys.argv`."
" The :mod:`argparse` module also automatically generates help and usage "
"messages and issues errors when users give the program invalid arguments."
msgstr ""
":mod:`argparse` 模块可以让人轻松编写用户友好的命令行接口。程序定义它需要的参数,然后 :mod:`argparse` 将弄清如何从 "
":data:`sys.argv` 解析出那些参数。 :mod:`argparse` "
"模块还会自动生成帮助和使用手册,并在用户给程序传入无效参数时报出错误信息。"
#: ../../library/argparse.rst:30
msgid "Example"
msgstr "示例"
#: ../../library/argparse.rst:32
msgid ""
"The following code is a Python program that takes a list of integers and "
"produces either the sum or the max::"
msgstr "以下代码是一个 Python 程序,它获取一个整数列表并计算总和或者最大值:"
#: ../../library/argparse.rst:47
msgid ""
"Assuming the Python code above is saved into a file called ``prog.py``, it "
"can be run at the command line and provides useful help messages:"
msgstr "假设上面的 Python 代码保存在名为 ``prog.py`` 的文件中,它可以在命令行运行并提供有用的帮助信息:"
#: ../../library/argparse.rst:64
msgid ""
"When run with the appropriate arguments, it prints either the sum or the max"
" of the command-line integers:"
msgstr "当使用适当的参数运行时,它会输出命令行传入整数的总和或者最大值:"
#: ../../library/argparse.rst:75
msgid "If invalid arguments are passed in, it will issue an error:"
msgstr "如果传入无效参数,则会报出错误:"
#: ../../library/argparse.rst:83
msgid "The following sections walk you through this example."
msgstr "以下部分将引导你完成这个示例。"
#: ../../library/argparse.rst:87
msgid "Creating a parser"
msgstr "创建一个解析器"
#: ../../library/argparse.rst:89
msgid ""
"The first step in using the :mod:`argparse` is creating an "
":class:`ArgumentParser` object::"
msgstr "使用 :mod:`argparse` 的第一步是创建一个 :class:`ArgumentParser` 对象:"
#: ../../library/argparse.rst:94
msgid ""
"The :class:`ArgumentParser` object will hold all the information necessary "
"to parse the command line into Python data types."
msgstr ":class:`ArgumentParser` 对象包含将命令行解析成 Python 数据类型所需的全部信息。"
#: ../../library/argparse.rst:99
msgid "Adding arguments"
msgstr "添加参数"
#: ../../library/argparse.rst:101
msgid ""
"Filling an :class:`ArgumentParser` with information about program arguments "
"is done by making calls to the :meth:`~ArgumentParser.add_argument` method. "
"Generally, these calls tell the :class:`ArgumentParser` how to take the "
"strings on the command line and turn them into objects. This information is"
" stored and used when :meth:`~ArgumentParser.parse_args` is called. For "
"example::"
msgstr ""
"给一个 :class:`ArgumentParser` 添加程序参数信息是通过调用 "
":meth:`~ArgumentParser.add_argument` 方法完成的。通常,这些调用指定 :class:`ArgumentParser`"
" 如何获取命令行字符串并将其转换为对象。这些信息在 :meth:`~ArgumentParser.parse_args` 调用时被存储和使用。例如:"
#: ../../library/argparse.rst:113
msgid ""
"Later, calling :meth:`~ArgumentParser.parse_args` will return an object with"
" two attributes, ``integers`` and ``accumulate``. The ``integers`` "
"attribute will be a list of one or more ints, and the ``accumulate`` "
"attribute will be either the :func:`sum` function, if ``--sum`` was "
"specified at the command line, or the :func:`max` function if it was not."
msgstr ""
"然后,调用 :meth:`~ArgumentParser.parse_args` 将返回一个具有 ``integers`` 和 "
"``accumulate`` 两个属性的对象。``integers`` 属性将是一个包含一个或多个整数的列表,而 ``accumulate`` "
"属性当命令行中指定了 ``--sum`` 参数时将是 :func:`sum` 函数,否则则是 :func:`max` 函数。"
#: ../../library/argparse.rst:121
msgid "Parsing arguments"
msgstr "解析参数"
#: ../../library/argparse.rst:123
msgid ""
":class:`ArgumentParser` parses arguments through the "
":meth:`~ArgumentParser.parse_args` method. This will inspect the command "
"line, convert each argument to the appropriate type and then invoke the "
"appropriate action. In most cases, this means a simple :class:`Namespace` "
"object will be built up from attributes parsed out of the command line::"
msgstr ""
":class:`ArgumentParser` 通过 :meth:`~ArgumentParser.parse_args` "
"方法解析参数。它将检查命令行,把每个参数转换为适当的类型然后调用相应的操作。在大多数情况下,这意味着一个简单的 :class:`Namespace` "
"对象将从命令行解析出的属性构建:"
#: ../../library/argparse.rst:132
msgid ""
"In a script, :meth:`~ArgumentParser.parse_args` will typically be called "
"with no arguments, and the :class:`ArgumentParser` will automatically "
"determine the command-line arguments from :data:`sys.argv`."
msgstr ""
"在脚本中,通常 :meth:`~ArgumentParser.parse_args` 会被不带参数调用,而 "
":class:`ArgumentParser` 将自动从 :data:`sys.argv` 中确定命令行参数。"
#: ../../library/argparse.rst:138
msgid "ArgumentParser objects"
msgstr "ArgumentParser 对象"
#: ../../library/argparse.rst:147
msgid ""
"Create a new :class:`ArgumentParser` object. All parameters should be passed"
" as keyword arguments. Each parameter has its own more detailed description "
"below, but in short they are:"
msgstr ""
"创建一个新的 :class:`ArgumentParser` "
"对象。所有的参数都应当作为关键字参数传入。每个参数在下面都有它更详细的描述,但简而言之,它们是:"
#: ../../library/argparse.rst:151
msgid "prog_ - The name of the program (default: ``sys.argv[0]``)"
msgstr ""
#: ../../library/argparse.rst:153
msgid ""
"usage_ - The string describing the program usage (default: generated from "
"arguments added to parser)"
msgstr "usage_ - 描述程序用途的字符串(默认值:从添加到解析器的参数生成)"
#: ../../library/argparse.rst:156
msgid ""
"description_ - Text to display before the argument help (default: none)"
msgstr ""
#: ../../library/argparse.rst:158
msgid "epilog_ - Text to display after the argument help (default: none)"
msgstr ""
#: ../../library/argparse.rst:160
msgid ""
"parents_ - A list of :class:`ArgumentParser` objects whose arguments should "
"also be included"
msgstr "parents_ - 一个 :class:`ArgumentParser` 对象的列表,它们的参数也应包含在内"
#: ../../library/argparse.rst:163
msgid "formatter_class_ - A class for customizing the help output"
msgstr "formatter_class_ - 用于自定义帮助文档输出格式的类"
#: ../../library/argparse.rst:165
msgid ""
"prefix_chars_ - The set of characters that prefix optional arguments "
"(default: '-')"
msgstr "prefix_chars_ - 可选参数的前缀字符集合(默认值: '-')"
#: ../../library/argparse.rst:168
msgid ""
"fromfile_prefix_chars_ - The set of characters that prefix files from which "
"additional arguments should be read (default: ``None``)"
msgstr "fromfile_prefix_chars_ - 当需要从文件中读取其他参数时,用于标识文件名的前缀字符集合(默认值: ``None``)"
#: ../../library/argparse.rst:171
msgid ""
"argument_default_ - The global default value for arguments (default: "
"``None``)"
msgstr "argument_default_ - 参数的全局默认值(默认值: ``None``)"
#: ../../library/argparse.rst:174
msgid ""
"conflict_handler_ - The strategy for resolving conflicting optionals "
"(usually unnecessary)"
msgstr "conflict_handler_ - 解决冲突选项的策略(通常是不必要的)"
#: ../../library/argparse.rst:177
msgid ""
"add_help_ - Add a ``-h/--help`` option to the parser (default: ``True``)"
msgstr "add_help_ - 为解析器添加一个 ``-h/--help`` 选项(默认值: ``True``)"
#: ../../library/argparse.rst:179
msgid ""
"allow_abbrev_ - Allows long options to be abbreviated if the abbreviation is"
" unambiguous. (default: ``True``)"
msgstr "allow_abbrev_ - 如果缩写是无歧义的,则允许缩写长选项 (默认值:``True``)"
#: ../../library/argparse.rst:182
msgid ""
"exit_on_error_ - Determines whether or not ArgumentParser exits with error "
"info when an error occurs. (default: ``True``)"
msgstr "exit_on_error_ - 决定当错误发生时是否让 ArgumentParser 附带错误信息退出。 (默认值: ``True``)"
#: ../../library/argparse.rst:185
msgid "*allow_abbrev* parameter was added."
msgstr "增加了 *allow_abbrev* 参数。"
#: ../../library/argparse.rst:188
msgid ""
"In previous versions, *allow_abbrev* also disabled grouping of short flags "
"such as ``-vv`` to mean ``-v -v``."
msgstr "在之前的版本中,*allow_abbrev* 还会禁用短旗标分组,例如 ``-vv`` 表示为 ``-v -v``。"
#: ../../library/argparse.rst:192
msgid "*exit_on_error* parameter was added."
msgstr "添加了 *exit_on_error* 形参。"
#: ../../library/argparse.rst:195 ../../library/argparse.rst:715
msgid "The following sections describe how each of these are used."
msgstr "以下部分描述这些参数如何使用。"
#: ../../library/argparse.rst:199
msgid "prog"
msgstr "prog"
#: ../../library/argparse.rst:201
msgid ""
"By default, :class:`ArgumentParser` objects use ``sys.argv[0]`` to determine"
" how to display the name of the program in help messages. This default is "
"almost always desirable because it will make the help messages match how the"
" program was invoked on the command line. For example, consider a file "
"named ``myprogram.py`` with the following code::"
msgstr ""
"默认情况下,:class:`ArgumentParser` 对象使用 ``sys.argv[0]`` "
"来确定如何在帮助消息中显示程序名称。这一默认值几乎总是可取的,因为它将使帮助消息与从命令行调用此程序的方式相匹配。例如,对于有如下代码的名为 "
"``myprogram.py`` 的文件:"
#: ../../library/argparse.rst:212
msgid ""
"The help for this program will display ``myprogram.py`` as the program name "
"(regardless of where the program was invoked from):"
msgstr "该程序的帮助信息将显示 ``myprogram.py`` 作为程序名称(无论程序从何处被调用):"
#: ../../library/argparse.rst:231
msgid ""
"To change this default behavior, another value can be supplied using the "
"``prog=`` argument to :class:`ArgumentParser`::"
msgstr "要更改这样的默认行为,可以使用 ``prog=`` 参数为 :class:`ArgumentParser` 指定另一个值:"
#: ../../library/argparse.rst:241
msgid ""
"Note that the program name, whether determined from ``sys.argv[0]`` or from "
"the ``prog=`` argument, is available to help messages using the ``%(prog)s``"
" format specifier."
msgstr ""
"需要注意的是,无论是从 ``sys.argv[0]`` 或是从 ``prog=`` 参数确定的程序名称,都可以在帮助消息里通过 ``%(prog)s``"
" 格式说明符来引用。"
#: ../../library/argparse.rst:258
msgid "usage"
msgstr "usage(用法)"
#: ../../library/argparse.rst:260
msgid ""
"By default, :class:`ArgumentParser` calculates the usage message from the "
"arguments it contains::"
msgstr "默认情况下,:class:`ArgumentParser` 根据它包含的参数来构建用法消息:"
#: ../../library/argparse.rst:276
msgid ""
"The default message can be overridden with the ``usage=`` keyword argument::"
msgstr "可以通过 ``usage=`` 关键字参数覆盖这一默认消息:"
#: ../../library/argparse.rst:291
msgid ""
"The ``%(prog)s`` format specifier is available to fill in the program name "
"in your usage messages."
msgstr "在用法消息中可以使用 ``%(prog)s`` 格式说明符来填入程序名称。"
#: ../../library/argparse.rst:296
msgid "description"
msgstr "description"
#: ../../library/argparse.rst:298
msgid ""
"Most calls to the :class:`ArgumentParser` constructor will use the "
"``description=`` keyword argument. This argument gives a brief description "
"of what the program does and how it works. In help messages, the "
"description is displayed between the command-line usage string and the help "
"messages for the various arguments::"
msgstr ""
"大多数对 :class:`ArgumentParser` 构造方法的调用都会使用 ``description=`` 关键字参数。 "
"这个参数简要描述这个程序做什么以及怎么做。 在帮助消息中,这个描述会显示在命令行用法字符串和各种参数的帮助消息之间::"
#: ../../library/argparse.rst:313
msgid ""
"By default, the description will be line-wrapped so that it fits within the "
"given space. To change this behavior, see the formatter_class_ argument."
msgstr "在默认情况下,description 将被换行以便适应给定的空间。如果想改变这种行为,见 formatter_class_ 参数。"
#: ../../library/argparse.rst:318
msgid "epilog"
msgstr "epilog"
#: ../../library/argparse.rst:320
msgid ""
"Some programs like to display additional description of the program after "
"the description of the arguments. Such text can be specified using the "
"``epilog=`` argument to :class:`ArgumentParser`::"
msgstr ""
"一些程序喜欢在 description 参数后显示额外的对程序的描述。这种文字能够通过给 :class:`ArgumentParser`:: 提供 "
"``epilog=`` 参数而被指定。"
#: ../../library/argparse.rst:337
msgid ""
"As with the description_ argument, the ``epilog=`` text is by default line-"
"wrapped, but this behavior can be adjusted with the formatter_class_ "
"argument to :class:`ArgumentParser`."
msgstr ""
"和 description_ 参数一样,``epilog=`` text 在默认情况下会换行,但是这种行为能够被调整通过提供 "
"formatter_class_ 参数给 :class:`ArgumentParse`."
#: ../../library/argparse.rst:343
msgid "parents"
msgstr "parents"
#: ../../library/argparse.rst:345
msgid ""
"Sometimes, several parsers share a common set of arguments. Rather than "
"repeating the definitions of these arguments, a single parser with all the "
"shared arguments and passed to ``parents=`` argument to "
":class:`ArgumentParser` can be used. The ``parents=`` argument takes a list"
" of :class:`ArgumentParser` objects, collects all the positional and "
"optional actions from them, and adds these actions to the "
":class:`ArgumentParser` object being constructed::"
msgstr ""
"有些时候,少数解析器会使用同一系列参数。 单个解析器能够通过提供 ``parents=`` 参数给 :class:`ArgumentParser` "
"而使用相同的参数而不是重复这些参数的定义。``parents=`` 参数使用 :class:`ArgumentParser` "
"对象的列表,从它们那里收集所有的位置和可选的行为,然后将这写行为加到正在构建的 :class:`ArgumentParser` 对象。"
#: ../../library/argparse.rst:365
msgid ""
"Note that most parent parsers will specify ``add_help=False``. Otherwise, "
"the :class:`ArgumentParser` will see two ``-h/--help`` options (one in the "
"parent and one in the child) and raise an error."
msgstr ""
"请注意大多数父解析器会指定 ``add_help=False`` . 否则, :class:`ArgumentParse` 将会看到两个 "
"``-h/--help`` 选项(一个在父参数中一个在子参数中)并且产生一个错误。"
#: ../../library/argparse.rst:370
msgid ""
"You must fully initialize the parsers before passing them via ``parents=``. "
"If you change the parent parsers after the child parser, those changes will "
"not be reflected in the child."
msgstr "你在通过 ``parents=`` 传递解析器之前必须完全初始化它们。 如果你在子解析器之后改变父解析器,这些改变将不会反映在子解析器上。"
#: ../../library/argparse.rst:376
msgid "formatter_class"
msgstr "formatter_class"
#: ../../library/argparse.rst:378
msgid ""
":class:`ArgumentParser` objects allow the help formatting to be customized "
"by specifying an alternate formatting class. Currently, there are four such"
" classes:"
msgstr ":class:`ArgumentParser` 对象允许通过指定备用格式化类来自定义帮助格式。目前,有四种这样的类。"
#: ../../library/argparse.rst:387
msgid ""
":class:`RawDescriptionHelpFormatter` and :class:`RawTextHelpFormatter` give "
"more control over how textual descriptions are displayed. By default, "
":class:`ArgumentParser` objects line-wrap the description_ and epilog_ texts"
" in command-line help messages::"
msgstr ""
":class:`RawDescriptionHelpFormatter` 和 :class:`RawTextHelpFormatter` "
"在正文的描述和展示上给与了更多的控制。:class:`ArgumentParser` 对象会将 description_ 和 epilog_ "
"的文字在命令行中自动换行。"
#: ../../library/argparse.rst:412
msgid ""
"Passing :class:`RawDescriptionHelpFormatter` as ``formatter_class=`` "
"indicates that description_ and epilog_ are already correctly formatted and "
"should not be line-wrapped::"
msgstr ""
"传 :class:`RawDescriptionHelpFormatter` 给 ``formatter_class=`` 表示 "
"description_ 和 epilog_ 已经被正确的格式化了,不能在命令行中被自动换行::"
#: ../../library/argparse.rst:438
msgid ""
":class:`RawTextHelpFormatter` maintains whitespace for all sorts of help "
"text, including argument descriptions. However, multiple new lines are "
"replaced with one. If you wish to preserve multiple blank lines, add spaces "
"between the newlines."
msgstr ""
":class:`RawTextHelpFormatter` "
"保留所有种类文字的空格,包括参数的描述。然而,多重的新行会被替换成一行。如果你想保留多重的空白行,可以在新行之间加空格。"
#: ../../library/argparse.rst:443
msgid ""
":class:`ArgumentDefaultsHelpFormatter` automatically adds information about "
"default values to each of the argument help messages::"
msgstr ":class:`ArgumentDefaultsHelpFormatter` 自动添加默认的值的信息到每一个帮助信息的参数中::"
#: ../../library/argparse.rst:461
msgid ""
":class:`MetavarTypeHelpFormatter` uses the name of the type_ argument for "
"each argument as the display name for its values (rather than using the "
"dest_ as the regular formatter does)::"
msgstr ""
":class:`MetavarTypeHelpFormatter` 为它的值在每一个参数中使用 type_ 的参数名当作它的显示名(而不是使用通常的格式"
" dest_ )::"
#: ../../library/argparse.rst:482
msgid "prefix_chars"
msgstr "prefix_chars"
#: ../../library/argparse.rst:484
msgid ""
"Most command-line options will use ``-`` as the prefix, e.g. ``-f/--foo``. "
"Parsers that need to support different or additional prefix characters, e.g."
" for options like ``+f`` or ``/foo``, may specify them using the "
"``prefix_chars=`` argument to the ArgumentParser constructor::"
msgstr ""
"许多命令行会使用 ``-`` 当作前缀,比如 ``-f/--foo``。如果解析器需要支持不同的或者额外的字符,比如像 ``+f`` 或者 "
"``/foo`` 的选项,可以在参数解析构建器中使用 ``prefix_chars=`` 参数。"
#: ../../library/argparse.rst:496
msgid ""
"The ``prefix_chars=`` argument defaults to ``'-'``. Supplying a set of "
"characters that does not include ``-`` will cause ``-f/--foo`` options to be"
" disallowed."
msgstr ""
"``prefix_chars=`` 参数默认使用 ``'-'``。 提供一组不包括 ``-`` 的字符将导致 ``-f/--foo`` 选项不被允许。"
#: ../../library/argparse.rst:502
msgid "fromfile_prefix_chars"
msgstr "fromfile_prefix_chars"
#: ../../library/argparse.rst:504
msgid ""
"Sometimes, for example when dealing with a particularly long argument list, "
"it may make sense to keep the list of arguments in a file rather than typing"
" it out at the command line. If the ``fromfile_prefix_chars=`` argument is "
"given to the :class:`ArgumentParser` constructor, then arguments that start "
"with any of the specified characters will be treated as files, and will be "
"replaced by the arguments they contain. For example::"
msgstr ""
"在某些时候,例如在处理一个特别长的参数列表的时候,把参数列表存入一个文件中而不是在命令行中打印出来会更有意义。 如果提供 "
"``fromfile_prefix_chars=`` 参数给 :class:`ArgumentParser` "
"构造器,则任何以指定字符打头的参数都将被当作文件来处理,并将被它们包含的参数所替代。 举例来说::"
#: ../../library/argparse.rst:518
msgid ""
"Arguments read from a file must by default be one per line (but see also "
":meth:`~ArgumentParser.convert_arg_line_to_args`) and are treated as if they"
" were in the same place as the original file referencing argument on the "
"command line. So in the example above, the expression ``['-f', 'foo', "
"'@args.txt']`` is considered equivalent to the expression ``['-f', 'foo', "
"'-f', 'bar']``."
msgstr ""
"从文件读取的参数在默认情况下必须一个一行(但是可参见 "
":meth:`~ArgumentParser.convert_arg_line_to_args`)并且它们被视为与命令行上的原始文件引用参数位于同一位置。所以在以上例子中,``['-f',"
" 'foo', '@args.txt']`` 的表示和 ``['-f', 'foo', '-f', 'bar']`` 的表示相同。"
#: ../../library/argparse.rst:524
msgid ""
"The ``fromfile_prefix_chars=`` argument defaults to ``None``, meaning that "
"arguments will never be treated as file references."
msgstr "``fromfile_prefix_chars=`` 参数默认为 ``None``,意味着参数不会被当作文件对待。"
#: ../../library/argparse.rst:529
msgid "argument_default"
msgstr "argument_default"
#: ../../library/argparse.rst:531
msgid ""
"Generally, argument defaults are specified either by passing a default to "
":meth:`~ArgumentParser.add_argument` or by calling the "
":meth:`~ArgumentParser.set_defaults` methods with a specific set of name-"
"value pairs. Sometimes however, it may be useful to specify a single "
"parser-wide default for arguments. This can be accomplished by passing the "
"``argument_default=`` keyword argument to :class:`ArgumentParser`. For "
"example, to globally suppress attribute creation on "
":meth:`~ArgumentParser.parse_args` calls, we supply "
"``argument_default=SUPPRESS``::"
msgstr ""
"一般情况下,参数默认会通过设置一个默认到 :meth:`~ArgumentParser.add_argument` 或者调用带一组指定键值对的 "
":meth:`ArgumentParser.set_defaults` 方法。但是有些时候,为参数指定一个普遍适用的解析器会更有用。这能够通过传输 "
"``argument_default=`` 关键词参数给 :class:`ArgumentParser` 来完成。举个栗子,要全局禁止在 "
":meth:`~ArgumentParser.parse_args` 中创建属性,我们提供 "
"``argument_default=SUPPRESS``::"
#: ../../library/argparse.rst:551
msgid "allow_abbrev"
msgstr "allow_abbrev"
#: ../../library/argparse.rst:553
msgid ""
"Normally, when you pass an argument list to the "
":meth:`~ArgumentParser.parse_args` method of an :class:`ArgumentParser`, it "
":ref:`recognizes abbreviations <prefix-matching>` of long options."
msgstr ""
"正常情况下,当你向 :class:`ArgumentParser` 的 :meth:`~ArgumentParser.parse_args` "
"方法传入一个参数列表时,它会 :ref:`recognizes abbreviations <prefix-matching>`。"
#: ../../library/argparse.rst:557
msgid ""
"This feature can be disabled by setting ``allow_abbrev`` to ``False``::"
msgstr "这个特性可以设置 ``allow_abbrev`` 为 ``False`` 来关闭::"
#: ../../library/argparse.rst:570
msgid "conflict_handler"
msgstr "conflict_handler"
#: ../../library/argparse.rst:572
msgid ""
":class:`ArgumentParser` objects do not allow two actions with the same "
"option string. By default, :class:`ArgumentParser` objects raise an "
"exception if an attempt is made to create an argument with an option string "
"that is already in use::"
msgstr ""
":class:`ArgumentParser` 对象不允许在相同选项字符串下有两种行为。默认情况下, :class:`ArgumentParser` "
"对象会产生一个异常如果去创建一个正在使用的选项字符串参数。"
#: ../../library/argparse.rst:584
msgid ""
"Sometimes (e.g. when using parents_) it may be useful to simply override any"
" older arguments with the same option string. To get this behavior, the "
"value ``'resolve'`` can be supplied to the ``conflict_handler=`` argument of"
" :class:`ArgumentParser`::"
msgstr ""
"有些时候(例如:使用 parents_),重写旧的有相同选项字符串的参数会更有用。为了产生这种行为, ``'resolve'`` 值可以提供给 "
":class:`ArgumentParser` 的 ``conflict_handler=`` 参数::"
#: ../../library/argparse.rst:600
msgid ""
"Note that :class:`ArgumentParser` objects only remove an action if all of "
"its option strings are overridden. So, in the example above, the old "
"``-f/--foo`` action is retained as the ``-f`` action, because only the "
"``--foo`` option string was overridden."
msgstr ""
"注意 :class:`ArgumentParser` 对象只能移除一个行为如果它所有的选项字符串都被重写。所以,在上面的例子中,旧的 "
"``-f/--foo`` 行为 回合 ``-f`` 行为保持一样, 因为只有 ``--foo`` 选项字符串被重写。"
#: ../../library/argparse.rst:607
msgid "add_help"
msgstr "add_help"
#: ../../library/argparse.rst:609
msgid ""
"By default, ArgumentParser objects add an option which simply displays the "
"parser's help message. For example, consider a file named ``myprogram.py`` "
"containing the following code::"
msgstr ""
"默认情况下,ArgumentParser 对象添加一个简单的显示解析器帮助信息的选项。举个栗子,考虑一个名为 ``myprogram.py`` "
"的文件包含如下代码::"
#: ../../library/argparse.rst:618
msgid ""
"If ``-h`` or ``--help`` is supplied at the command line, the ArgumentParser "
"help will be printed:"
msgstr "如果 ``-h`` or ``--help`` 在命令行中被提供, 参数解析器帮助信息会打印::"
#: ../../library/argparse.rst:630
msgid ""
"Occasionally, it may be useful to disable the addition of this help option. "
"This can be achieved by passing ``False`` as the ``add_help=`` argument to "
":class:`ArgumentParser`::"
msgstr ""
"有时候可能会需要关闭额外的帮助信息。这可以通过在 :class:`ArgumentParser` 中设置 ``add_help=`` 参数为 "
"``False`` 来实现。"
#: ../../library/argparse.rst:642
msgid ""
"The help option is typically ``-h/--help``. The exception to this is if the "
"``prefix_chars=`` is specified and does not include ``-``, in which case "
"``-h`` and ``--help`` are not valid options. In this case, the first "
"character in ``prefix_chars`` is used to prefix the help options::"
msgstr ""
"帮助选项一般为 ``-h/--help``。如果 ``prefix_chars=`` 被指定并且没有包含 ``-`` 字符,在这种情况下, ``-h``"
" ``--help`` 不是有效的选项。此时, ``prefix_chars`` 的第一个字符将用作帮助选项的前缀。"
#: ../../library/argparse.rst:657
msgid "exit_on_error"
msgstr "exit_on_error"
#: ../../library/argparse.rst:659
msgid ""
"Normally, when you pass an invalid argument list to the "
":meth:`~ArgumentParser.parse_args` method of an :class:`ArgumentParser`, it "
"will exit with error info."
msgstr ""
"正常情况下,当你向 :class:`ArgumentParser` 的 :meth:`~ArgumentParser.parse_args` "
"方法传入一个无效的参数列表时,它将会退出并发出错误信息。"
#: ../../library/argparse.rst:662
msgid ""
"If the user would like to catch errors manually, the feature can be enabled "
"by setting ``exit_on_error`` to ``False``::"
msgstr "如果用户想要手动捕获错误,可通过将 ``exit_on_error`` 设为 ``False`` 来启用该特性::"
#: ../../library/argparse.rst:679
msgid "The add_argument() method"
msgstr "add_argument() 方法"
#: ../../library/argparse.rst:685
msgid ""
"Define how a single command-line argument should be parsed. Each parameter "
"has its own more detailed description below, but in short they are:"
msgstr "定义单个的命令行参数应当如何解析。每个形参都在下面有它自己更多的描述,长话短说有:"
#: ../../library/argparse.rst:688
msgid ""
"`name or flags`_ - Either a name or a list of option strings, e.g. ``foo`` "
"or ``-f, --foo``."
msgstr "`name or flags`_ - 一个命名或者一个选项字符串的列表,例如 ``foo`` 或 ``-f, --foo``。"
#: ../../library/argparse.rst:691
msgid ""
"action_ - The basic type of action to be taken when this argument is "
"encountered at the command line."
msgstr "action_ - 当参数在命令行中出现时使用的动作基本类型。"
#: ../../library/argparse.rst:694
msgid "nargs_ - The number of command-line arguments that should be consumed."
msgstr "nargs_ - 命令行参数应当消耗的数目。"
#: ../../library/argparse.rst:696
msgid ""
"const_ - A constant value required by some action_ and nargs_ selections."
msgstr "const_ - 被一些 action_ 和 nargs_ 选择所需求的常数。"
#: ../../library/argparse.rst:698
msgid ""
"default_ - The value produced if the argument is absent from the command "
"line and if it is absent from the namespace object."
msgstr "default_ - 当参数未在命令行中出现并且也不存在于命名空间对象时所产生的值。"
#: ../../library/argparse.rst:701
msgid ""
"type_ - The type to which the command-line argument should be converted."
msgstr "type_ - 命令行参数应当被转换成的类型。"
#: ../../library/argparse.rst:703
msgid "choices_ - A container of the allowable values for the argument."
msgstr ""
#: ../../library/argparse.rst:705
msgid ""
"required_ - Whether or not the command-line option may be omitted (optionals"
" only)."
msgstr "required_ - 此命令行选项是否可省略 (仅选项可用)。"
#: ../../library/argparse.rst:708
msgid "help_ - A brief description of what the argument does."
msgstr "help_ - 一个此选项作用的简单描述。"
#: ../../library/argparse.rst:710
msgid "metavar_ - A name for the argument in usage messages."
msgstr "metavar_ - 在使用方法消息中使用的参数值示例。"
#: ../../library/argparse.rst:712
msgid ""
"dest_ - The name of the attribute to be added to the object returned by "
":meth:`parse_args`."
msgstr "dest_ - 被添加到 :meth:`parse_args` 所返回对象上的属性名。"
#: ../../library/argparse.rst:719
msgid "name or flags"
msgstr "name or flags"
#: ../../library/argparse.rst:721
msgid ""
"The :meth:`~ArgumentParser.add_argument` method must know whether an "
"optional argument, like ``-f`` or ``--foo``, or a positional argument, like "
"a list of filenames, is expected. The first arguments passed to "
":meth:`~ArgumentParser.add_argument` must therefore be either a series of "
"flags, or a simple argument name. For example, an optional argument could "
"be created like::"
msgstr ""
":meth:`~ArgumentParser.add_argument` 方法必须知道它是否是一个选项,例如 ``-f`` 或 "
"``--foo``,或是一个位置参数,例如一组文件名。 第一个传递给 :meth:`~ArgumentParser.add_argument` "
"的参数必须是一系列旗标或者是一个简单的参数名。例如,可选参数可以被这样创建::"
#: ../../library/argparse.rst:730
msgid "while a positional argument could be created like::"
msgstr "而位置参数可以这么创建::"
#: ../../library/argparse.rst:734
msgid ""
"When :meth:`~ArgumentParser.parse_args` is called, optional arguments will "
"be identified by the ``-`` prefix, and the remaining arguments will be "
"assumed to be positional::"
msgstr ""
"当 :meth:`~ArgumentParser.parse_args` 被调用,选项会以 ``-`` 前缀识别,剩下的参数则会被假定为位置参数::"
#: ../../library/argparse.rst:751
msgid "action"
msgstr "action"
#: ../../library/argparse.rst:753
msgid ""
":class:`ArgumentParser` objects associate command-line arguments with "
"actions. These actions can do just about anything with the command-line "
"arguments associated with them, though most actions simply add an attribute "
"to the object returned by :meth:`~ArgumentParser.parse_args`. The "
"``action`` keyword argument specifies how the command-line arguments should "
"be handled. The supplied actions are:"
msgstr ""
":class:`ArgumentParser` 对象将命令行参数与动作相关联。这些动作可以做与它们相关联的命令行参数的任何事,尽管大多数动作只是简单的向"
" :meth:`~ArgumentParser.parse_args` 返回的对象上添加属性。``action`` "
"命名参数指定了这个命令行参数应当如何处理。供应的动作有:"
#: ../../library/argparse.rst:759
msgid ""
"``'store'`` - This just stores the argument's value. This is the default "
"action. For example::"
msgstr "``'store'`` - 存储参数的值。这是默认的动作。例如::"
#: ../../library/argparse.rst:767
msgid ""
"``'store_const'`` - This stores the value specified by the const_ keyword "
"argument. The ``'store_const'`` action is most commonly used with optional "
"arguments that specify some sort of flag. For example::"
msgstr ""
"``'store_const'`` - 存储被 const_ 命名参数指定的值。 ``'store_const'`` "
"动作通常用在选项中来指定一些标志。例如::"
#: ../../library/argparse.rst:776
msgid ""
"``'store_true'`` and ``'store_false'`` - These are special cases of "
"``'store_const'`` used for storing the values ``True`` and ``False`` "
"respectively. In addition, they create default values of ``False`` and "
"``True`` respectively. For example::"
msgstr ""
"``'store_true'`` and ``'store_false'`` - 这些是 ``'store_const'`` 分别用作存储 "
"``True`` 和 ``False`` 值的特殊用例。另外,它们的默认值分别为 ``False`` 和 ``True``。例如::"
#: ../../library/argparse.rst:788
msgid ""
"``'append'`` - This stores a list, and appends each argument value to the "
"list. This is useful to allow an option to be specified multiple times. "
"Example usage::"
msgstr "``'append'`` - 存储一个列表,并且将每个参数值追加到列表中。在允许多次使用选项时很有用。例如::"
#: ../../library/argparse.rst:797
msgid ""
"``'append_const'`` - This stores a list, and appends the value specified by "
"the const_ keyword argument to the list. (Note that the const_ keyword "
"argument defaults to ``None``.) The ``'append_const'`` action is typically "
"useful when multiple arguments need to store constants to the same list. For"
" example::"
msgstr ""
"``'append_const'`` - 这存储一个列表,并将 const_ 命名参数指定的值追加到列表中。(注意 const_ 命名参数默认为 "
"``None``。)``'append_const'`` 动作一般在多个参数需要在同一列表中存储常数时会有用。例如::"
#: ../../library/argparse.rst:809
msgid ""
"``'count'`` - This counts the number of times a keyword argument occurs. For"
" example, this is useful for increasing verbosity levels::"
msgstr "``'count'`` - 计算一个关键字参数出现的数目或次数。例如,对于一个增长的详情等级来说有用::"
#: ../../library/argparse.rst:817
msgid "Note, the *default* will be ``None`` unless explicitly set to *0*."
msgstr "请注意,*default* 将为 ``None``,除非显式地设为 *0*。"
#: ../../library/argparse.rst:819
msgid ""
"``'help'`` - This prints a complete help message for all the options in the "
"current parser and then exits. By default a help action is automatically "
"added to the parser. See :class:`ArgumentParser` for details of how the "
"output is created."
msgstr ""
"``'help'`` - 打印所有当前解析器中的选项和参数的完整帮助信息,然后退出。默认情况下,一个 help "
"动作会被自动加入解析器。关于输出是如何创建的,参与 :class:`ArgumentParser`。"
#: ../../library/argparse.rst:824
msgid ""
"``'version'`` - This expects a ``version=`` keyword argument in the "
":meth:`~ArgumentParser.add_argument` call, and prints version information "
"and exits when invoked::"
msgstr ""
"``'version'`` - 期望有一个 ``version=`` 命名参数在 "
":meth:`~ArgumentParser.add_argument` 调用中,并打印版本信息并在调用后退出::"
#: ../../library/argparse.rst:834
msgid ""
"``'extend'`` - This stores a list, and extends each argument value to the "
"list. Example usage::"
msgstr "``'extend'`` - 这会存储一个列表,并将每个参数值加入到列表中。 示例用法::"
#: ../../library/argparse.rst:845
msgid ""
"You may also specify an arbitrary action by passing an Action subclass or "
"other object that implements the same interface. The "
"``BooleanOptionalAction`` is available in ``argparse`` and adds support for "
"boolean actions such as ``--foo`` and ``--no-foo``::"
msgstr ""
"你还可以通过传递一个 Action 子类或实现相同接口的其他对象来指定任意操作。 ``BooleanOptionalAction`` 在 "
"``argparse`` 中可用并会添加对布尔型操作例如 ``--foo`` 和 ``--no-foo`` 的支持::"
#: ../../library/argparse.rst:858
msgid ""
"The recommended way to create a custom action is to extend :class:`Action`, "
"overriding the ``__call__`` method and optionally the ``__init__`` and "
"``format_usage`` methods."
msgstr ""
"创建自定义动作的推荐方式是扩展 :class:`Action`,重写 ``__call__`` 方法以及可选的 ``__init__`` 和 "
"``format_usage`` 方法。"
#: ../../library/argparse.rst:862
msgid "An example of a custom action::"
msgstr "一个自定义动作的例子::"
#: ../../library/argparse.rst:882
msgid "For more details, see :class:`Action`."
msgstr "更多描述,见 :class:`Action`。"
#: ../../library/argparse.rst:885
msgid "nargs"
msgstr "nargs"
#: ../../library/argparse.rst:887
msgid ""
"ArgumentParser objects usually associate a single command-line argument with"
" a single action to be taken. The ``nargs`` keyword argument associates a "
"different number of command-line arguments with a single action. The "
"supported values are:"
msgstr ""
"ArgumentParser 对象通常关联一个单独的命令行参数到一个单独的被执行的动作。 ``nargs`` "
"命名参数关联不同数目的命令行参数到单一动作。支持的值有:"
#: ../../library/argparse.rst:892
msgid ""
"``N`` (an integer). ``N`` arguments from the command line will be gathered "
"together into a list. For example::"
msgstr "``N`` (一个整数)。命令行中的 ``N`` 个参数会被聚集到一个列表中。 例如::"
#: ../../library/argparse.rst:901
msgid ""
"Note that ``nargs=1`` produces a list of one item. This is different from "
"the default, in which the item is produced by itself."
msgstr "注意 ``nargs=1`` 会产生一个单元素列表。这和默认的元素本身是不同的。"
#: ../../library/argparse.rst:906
msgid ""
"``'?'``. One argument will be consumed from the command line if possible, "
"and produced as a single item. If no command-line argument is present, the "
"value from default_ will be produced. Note that for optional arguments, "
"there is an additional case - the option string is present but not followed "
"by a command-line argument. In this case the value from const_ will be "
"produced. Some examples to illustrate this::"
msgstr ""
"``'?'``。 如果可能的话,会从命令行中消耗一个参数,并产生一个单独项。 如果当前没有命令行参数,将会产生 default_ 值。 "
"注意对于可选参数来说,还有一个额外情况 —— 出现了选项字符串但没有跟随命令行参数,在此情况下将会产生 const_ 值。 "
"一些说明这种情况的例子如下::"
#: ../../library/argparse.rst:923
msgid ""
"One of the more common uses of ``nargs='?'`` is to allow optional input and "
"output files::"
msgstr "``nargs='?'`` 的一个更普遍用法是允许可选的输入或输出文件::"
#: ../../library/argparse.rst:940
msgid ""
"``'*'``. All command-line arguments present are gathered into a list. Note"
" that it generally doesn't make much sense to have more than one positional "
"argument with ``nargs='*'``, but multiple optional arguments with "
"``nargs='*'`` is possible. For example::"
msgstr ""
"``'*'``。所有当前命令行参数被聚集到一个列表中。注意通过 ``nargs='*'`` "
"来实现多个位置参数通常没有意义,但是多个选项是可能的。例如::"
#: ../../library/argparse.rst:954
msgid ""
"``'+'``. Just like ``'*'``, all command-line args present are gathered into "
"a list. Additionally, an error message will be generated if there wasn't at"
" least one command-line argument present. For example::"
msgstr ""
"``'+'``。和 ``'*'`` 类似,所有当前命令行参数被聚集到一个列表中。另外,当前没有至少一个命令行参数时会产生一个错误信息。例如::"
#: ../../library/argparse.rst:966
msgid ""
"If the ``nargs`` keyword argument is not provided, the number of arguments "
"consumed is determined by the action_. Generally this means a single "
"command-line argument will be consumed and a single item (not a list) will "
"be produced."
msgstr "如果不提供 ``nargs`` 命名参数,则消耗参数的数目将被 action_ 决定。通常这意味着单一项目(非列表)消耗单一命令行参数。"
#: ../../library/argparse.rst:972
msgid "const"
msgstr "const"
#: ../../library/argparse.rst:974
msgid ""
"The ``const`` argument of :meth:`~ArgumentParser.add_argument` is used to "
"hold constant values that are not read from the command line but are "
"required for the various :class:`ArgumentParser` actions. The two most "
"common uses of it are:"
msgstr ""
":meth:`~ArgumentParser.add_argument` 的 ``const`` 参数用于保存不从命令行中读取但被各种 "
":class:`ArgumentParser` 动作需求的常数值。最常用的两例为:"
#: ../../library/argparse.rst:978
msgid ""
"When :meth:`~ArgumentParser.add_argument` is called with "
"``action='store_const'`` or ``action='append_const'``. These actions add "
"the ``const`` value to one of the attributes of the object returned by "
":meth:`~ArgumentParser.parse_args`. See the action_ description for "
"examples."
msgstr ""
"当 :meth:`~ArgumentParser.add_argument` 通过 ``action='store_const'`` 或 "
"``action='append_const`` 调用时。这些动作将 ``const`` 值添加到 "
":meth:`~ArgumentParser.parse_args` 返回的对象的属性中。在 action_ 的描述中查看案例。"
#: ../../library/argparse.rst:983
msgid ""
"When :meth:`~ArgumentParser.add_argument` is called with option strings "
"(like ``-f`` or ``--foo``) and ``nargs='?'``. This creates an optional "
"argument that can be followed by zero or one command-line arguments. When "
"parsing the command line, if the option string is encountered with no "
"command-line argument following it, the value of ``const`` will be assumed "
"instead. See the nargs_ description for examples."
msgstr ""
"当 :meth:`~ArgumentParser.add_argument` 通过选项(例如 ``-f`` 或 ``--foo``)调用并且 "
"``nargs='?'`` 时。这会创建一个可以跟随零个或一个命令行参数的选项。当解析命令行时,如果选项后没有参数,则将用 ``const`` 代替。在"
" nargs_ 描述中查看案例。"
#: ../../library/argparse.rst:990
msgid ""
"With the ``'store_const'`` and ``'append_const'`` actions, the ``const`` "
"keyword argument must be given. For other actions, it defaults to ``None``."
msgstr ""
"对 ``'store_const'`` 和 ``'append_const'`` 动作, ``const`` 命名参数必须给出。对其他动作,默认为 "
"``None``。"
#: ../../library/argparse.rst:995
msgid "default"
msgstr "默认值"
#: ../../library/argparse.rst:997
msgid ""
"All optional arguments and some positional arguments may be omitted at the "
"command line. The ``default`` keyword argument of "
":meth:`~ArgumentParser.add_argument`, whose value defaults to ``None``, "
"specifies what value should be used if the command-line argument is not "
"present. For optional arguments, the ``default`` value is used when the "
"option string was not present at the command line::"
msgstr ""
"所有选项和一些位置参数可能在命令行中被忽略。:meth:`~ArgumentParser.add_argument` 的命名参数 "
"``default``,默认值为 ``None``,指定了在命令行参数未出现时应当使用的值。对于选项, ``default`` "
"值在选项未在命令行中出现时使用::"
#: ../../library/argparse.rst:1011
msgid ""
"If the target namespace already has an attribute set, the action *default* "
"will not over write it::"
msgstr "如果目标命名空间已经有一个属性集,则 *default* 动作不会覆盖它::"
#: ../../library/argparse.rst:1019
msgid ""
"If the ``default`` value is a string, the parser parses the value as if it "