forked from python/python-docs-zh-tw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathargparse.po
More file actions
4500 lines (4096 loc) · 180 KB
/
argparse.po
File metadata and controls
4500 lines (4096 loc) · 180 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
# Copyright (C) 2001 Python Software Foundation
# This file is distributed under the same license as the Python package.
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: Python 3.14\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-04-15 00:29+0000\n"
"PO-Revision-Date: 2018-05-23 14:38+0000\n"
"Last-Translator: Adrian Liaw <adrianliaw2000@gmail.com>\n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
"tw)\n"
"Language: zh_TW\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: ../../library/argparse.rst:2
msgid ""
":mod:`!argparse` --- Parser for command-line options, arguments and "
"subcommands"
msgstr ":mod:`!argparse` --- 命令列選項、引數和子命令的剖析器"
#: ../../library/argparse.rst:12
msgid "**Source code:** :source:`Lib/argparse.py`"
msgstr "**原始碼:**\\ :source:`Lib/argparse.py`"
#: ../../library/argparse.rst:16
msgid ""
"While :mod:`!argparse` is the default recommended standard library module "
"for implementing basic command line applications, authors with more exacting "
"requirements for exactly how their command line applications behave may find "
"it doesn't provide the necessary level of control. Refer to :ref:`choosing-"
"an-argument-parser` for alternatives to consider when ``argparse`` doesn't "
"support behaviors that the application requires (such as entirely disabling "
"support for interspersed options and positional arguments, or accepting "
"option parameter values that start with ``-`` even when they correspond to "
"another defined option)."
msgstr ""
"雖然 :mod:`!argparse` 是實作基本命令列應用程式時預設推薦的標準函式庫模組,但"
"如果開發者對命令列應用程式的行為有更精確的要求,可能會發現它無法提供足夠的控"
"制程度。當 ``argparse`` 不支援應用程式所需的行為時(例如完全停用交錯選項與位"
"置引數的支援,或是允許以 ``-`` 開頭但可能與其他已定義選項相同的選項參數值),"
"請參閱\\ :ref:`choosing-an-argument-parser`\\ 以了解替代方案。"
#: ../../library/argparse.rst:-1
msgid "Tutorial"
msgstr "教學"
#: ../../library/argparse.rst:30
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:34
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. The module will also issue errors when users give the program "
"invalid arguments."
msgstr ""
":mod:`!argparse` 模組使得撰寫使用者友善的命令列介面變得容易。程式定義它需要什"
"麼引數,而 :mod:`!argparse` 會找出如何從 :data:`sys.argv` 中剖析這些引數。:"
"mod:`!argparse` 模組也會自動產生說明和用法訊息。當使用者向程式提供無效引數"
"時,此模組也會發出錯誤。"
#: ../../library/argparse.rst:40
msgid ""
"The :mod:`!argparse` module's support for command-line interfaces is built "
"around an instance of :class:`argparse.ArgumentParser`. It is a container "
"for argument specifications and has options that apply to the parser as "
"whole::"
msgstr ""
":mod:`!argparse` 模組對命令列介面的支援是圍繞 :class:`argparse."
"ArgumentParser` 的實例建構的。它是引數規格的容器,並具有適用於整個剖析器的選"
"項: ::"
#: ../../library/argparse.rst:44
msgid ""
"parser = argparse.ArgumentParser(\n"
" prog='ProgramName',\n"
" description='What the program does',\n"
" epilog='Text at the bottom of help')"
msgstr ""
"parser = argparse.ArgumentParser(\n"
" prog='ProgramName',\n"
" description='What the program does',\n"
" epilog='Text at the bottom of help')"
#: ../../library/argparse.rst:49
msgid ""
"The :meth:`ArgumentParser.add_argument` method attaches individual argument "
"specifications to the parser. It supports positional arguments, options "
"that accept values, and on/off flags::"
msgstr ""
":meth:`ArgumentParser.add_argument` 方法會將個別的引數規格附加到剖析器。它支"
"援位置引數、接受值的選項以及開關旗標:::"
#: ../../library/argparse.rst:53
msgid ""
"parser.add_argument('filename') # positional argument\n"
"parser.add_argument('-c', '--count') # option that takes a value\n"
"parser.add_argument('-v', '--verbose',\n"
" action='store_true') # on/off flag"
msgstr ""
"parser.add_argument('filename') # 位置引數\n"
"parser.add_argument('-c', '--count') # 接收一個值的選項\n"
"parser.add_argument('-v', '--verbose',\n"
" action='store_true') # 開關旗標"
#: ../../library/argparse.rst:58
msgid ""
"The :meth:`ArgumentParser.parse_args` method runs the parser and places the "
"extracted data in a :class:`argparse.Namespace` object::"
msgstr ""
":meth:`ArgumentParser.parse_args` 方法會執行剖析器,並將擷取的資料放入一個 :"
"class:`argparse.Namespace` 物件中:::"
#: ../../library/argparse.rst:61
msgid ""
"args = parser.parse_args()\n"
"print(args.filename, args.count, args.verbose)"
msgstr ""
"args = parser.parse_args()\n"
"print(args.filename, args.count, args.verbose)"
#: ../../library/argparse.rst:65
msgid ""
"If you're looking for a guide about how to upgrade :mod:`optparse` code to :"
"mod:`!argparse`, see :ref:`Upgrading Optparse Code <upgrading-optparse-"
"code>`."
msgstr ""
"如果你在尋找如何將 :mod:`optparse` 程式碼升級到 :mod:`!argparse` 的指南,請參"
"閱\\ :ref:`升級 Optparse 程式碼 <upgrading-optparse-code>`。"
#: ../../library/argparse.rst:69
msgid "ArgumentParser objects"
msgstr "ArgumentParser 物件"
#: ../../library/argparse.rst:79
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:83
msgid ""
"prog_ - The name of the program (default: generated from the ``__main__`` "
"module attributes and ``sys.argv[0]``)"
msgstr ""
"prog_ - 程式的名稱(預設值:從 ``__main__`` 模組屬性和 ``sys.argv[0]`` 產生)"
#: ../../library/argparse.rst:86
msgid ""
"usage_ - The string describing the program usage (default: generated from "
"arguments added to parser)"
msgstr "usage_ - 描述程式用法的字串(預設值:從新增到剖析器的引數產生)"
#: ../../library/argparse.rst:89
msgid ""
"description_ - Text to display before the argument help (by default, no text)"
msgstr "description_ - 引數說明之前要顯示的文字(預設值:無文字)"
#: ../../library/argparse.rst:92
msgid "epilog_ - Text to display after the argument help (by default, no text)"
msgstr "epilog_ - 引數說明之後要顯示的文字(預設值:無文字)"
#: ../../library/argparse.rst:94
msgid ""
"parents_ - A list of :class:`ArgumentParser` objects whose arguments should "
"also be included"
msgstr "parents_ - 一個 :class:`ArgumentParser` 物件的串列,其引數也應該被包含"
#: ../../library/argparse.rst:97
msgid "formatter_class_ - A class for customizing the help output"
msgstr "formatter_class_ - 用於自訂幫助說明輸出的類別"
#: ../../library/argparse.rst:99
msgid ""
"prefix_chars_ - The set of characters that prefix optional arguments "
"(default: '-')"
msgstr "prefix_chars_ - 前綴可選引數的字元集合(預設值:'-')"
#: ../../library/argparse.rst:102
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:105
msgid ""
"argument_default_ - The global default value for arguments (default: "
"``None``)"
msgstr "argument_default_ - 引數的全域預設值(預設值:``None``)"
#: ../../library/argparse.rst:108
msgid ""
"conflict_handler_ - The strategy for resolving conflicting optionals "
"(usually unnecessary)"
msgstr "conflict_handler_ - 解決衝突可選引數的策略(通常不需要)"
#: ../../library/argparse.rst:111
msgid ""
"add_help_ - Add a ``-h/--help`` option to the parser (default: ``True``)"
msgstr "add_help_ - 加入一個 ``-h/--help`` 選項到剖析器(預設值:``True``)"
#: ../../library/argparse.rst:113
msgid ""
"allow_abbrev_ - Allows long options to be abbreviated if the abbreviation is "
"unambiguous (default: ``True``)"
msgstr ""
"allow_abbrev_ - 允許長選項被縮寫,只要縮寫是無歧義的(預設值:``True``)"
#: ../../library/argparse.rst:116
msgid ""
"exit_on_error_ - Determines whether or not :class:`!ArgumentParser` exits "
"with error info when an error occurs. (default: ``True``)"
msgstr ""
"exit_on_error_ - 決定 :class:`!ArgumentParser` 在發生錯誤時是否帶著錯誤資訊退"
"出。(預設值:``True``)"
#: ../../library/argparse.rst:119
msgid ""
"suggest_on_error_ - Enables suggestions for mistyped argument choices and "
"subparser names (default: ``False``)"
msgstr ""
"suggest_on_error_ - 啟用對拼錯的引數選擇和子剖析器名稱的建議(預設值:"
"``False``)"
#: ../../library/argparse.rst:122
msgid "color_ - Allow color output (default: ``True``)"
msgstr "color_ - 允許彩色輸出(預設值:``True``)"
#: ../../library/argparse.rst:124
msgid "*allow_abbrev* parameter was added."
msgstr "新增 *allow_abbrev* 參數。"
#: ../../library/argparse.rst:127
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:131
msgid "*exit_on_error* parameter was added."
msgstr "新增 *exit_on_error* 參數。"
#: ../../library/argparse.rst:134
msgid "*suggest_on_error* and *color* parameters were added."
msgstr "新增 *suggest_on_error* 和 *color* 參數。"
#: ../../library/argparse.rst:137 ../../library/argparse.rst:696
msgid "The following sections describe how each of these are used."
msgstr "以下各節描述了這些參數的使用方式。"
#: ../../library/argparse.rst:143
msgid "prog"
msgstr "prog"
#: ../../library/argparse.rst:146
msgid ""
"By default, :class:`ArgumentParser` calculates the name of the program to "
"display in help messages depending on the way the Python interpreter was run:"
msgstr ""
"預設情況下,:class:`ArgumentParser` 會根據 Python 直譯器的執行方式計算要在說"
"明訊息中顯示的程式名稱:"
#: ../../library/argparse.rst:149
msgid ""
"The :func:`base name <os.path.basename>` of ``sys.argv[0]`` if a file was "
"passed as argument."
msgstr ""
"如果傳入的引數是一個檔案,則使用 ``sys.argv[0]`` 的\\ :func:`基底名稱 <os."
"path.basename>`。"
#: ../../library/argparse.rst:151
msgid ""
"The Python interpreter name followed by ``sys.argv[0]`` if a directory or a "
"zipfile was passed as argument."
msgstr ""
"如果傳入的引數是一個目錄或 zip 檔案,則使用 Python 直譯器名稱加上 ``sys."
"argv[0]``。"
#: ../../library/argparse.rst:153
msgid ""
"The Python interpreter name followed by ``-m`` followed by the module or "
"package name if the :option:`-m` option was used."
msgstr ""
"如果使用了 :option:`-m` 選項,則使用 Python 直譯器名稱加上 ``-m`` 再加上模組"
"或套件名稱。"
#: ../../library/argparse.rst:156
msgid ""
"This default is almost always desirable because it will make the help "
"messages match the string that was used to invoke the program on the command "
"line. However, to change this default behavior, another value can be "
"supplied using the ``prog=`` argument to :class:`ArgumentParser`::"
msgstr ""
"這個預設值幾乎都不會錯,因為它會使說明訊息與命令列上呼叫程式時所用的字串一"
"致。然而,若要更改此預設行為,可以使用 :class:`ArgumentParser` 的 ``prog=`` "
"引數提供另一個值: ::"
#: ../../library/argparse.rst:161
msgid ""
">>> parser = argparse.ArgumentParser(prog='myprogram')\n"
">>> parser.print_help()\n"
"usage: myprogram [-h]\n"
"\n"
"options:\n"
" -h, --help show this help message and exit"
msgstr ""
">>> parser = argparse.ArgumentParser(prog='myprogram')\n"
">>> parser.print_help()\n"
"usage: myprogram [-h]\n"
"\n"
"options:\n"
" -h, --help show this help message and exit"
#: ../../library/argparse.rst:168
msgid ""
"Note that the program name, whether determined from ``sys.argv[0]``, from "
"the ``__main__`` module attributes or from the ``prog=`` argument, is "
"available to help messages using the ``%(prog)s`` format specifier."
msgstr ""
"請注意,無論程式名稱是從 ``sys.argv[0]``、從 ``__main__`` 模組屬性還是從 "
"``prog=`` 引數決定的,都可以在說明訊息中透過 ``%(prog)s`` 格式說明符號使用。"
#: ../../library/argparse.rst:175
msgid ""
">>> parser = argparse.ArgumentParser(prog='myprogram')\n"
">>> parser.add_argument('--foo', help='foo of the %(prog)s program')\n"
">>> parser.print_help()\n"
"usage: myprogram [-h] [--foo FOO]\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --foo FOO foo of the myprogram program"
msgstr ""
">>> parser = argparse.ArgumentParser(prog='myprogram')\n"
">>> parser.add_argument('--foo', help='foo of the %(prog)s program')\n"
">>> parser.print_help()\n"
"usage: myprogram [-h] [--foo FOO]\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --foo FOO foo of the myprogram program"
#: ../../library/argparse.rst:184
msgid ""
"The default ``prog`` value now reflects how ``__main__`` was actually "
"executed, rather than always being ``os.path.basename(sys.argv[0])``."
msgstr ""
"預設的 ``prog`` 值現在會反映 ``__main__`` 實際的執行方式,而非總是使用 ``os."
"path.basename(sys.argv[0])``。"
#: ../../library/argparse.rst:189
msgid "usage"
msgstr "usage"
#: ../../library/argparse.rst:191
msgid ""
"By default, :class:`ArgumentParser` calculates the usage message from the "
"arguments it contains. The default message can be overridden with the "
"``usage=`` keyword argument::"
msgstr ""
"預設情況下,:class:`ArgumentParser` 會根據它包含的引數計算出用法訊息。可以使"
"用 ``usage=`` 關鍵字引數覆寫預設訊息: ::"
#: ../../library/argparse.rst:195
msgid ""
">>> parser = argparse.ArgumentParser(prog='PROG', usage='%(prog)s "
"[options]')\n"
">>> parser.add_argument('--foo', nargs='?', help='foo help')\n"
">>> parser.add_argument('bar', nargs='+', help='bar help')\n"
">>> parser.print_help()\n"
"usage: PROG [options]\n"
"\n"
"positional arguments:\n"
" bar bar help\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --foo [FOO] foo help"
msgstr ""
">>> parser = argparse.ArgumentParser(prog='PROG', usage='%(prog)s "
"[options]')\n"
">>> parser.add_argument('--foo', nargs='?', help='foo help')\n"
">>> parser.add_argument('bar', nargs='+', help='bar help')\n"
">>> parser.print_help()\n"
"usage: PROG [options]\n"
"\n"
"positional arguments:\n"
" bar bar help\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --foo [FOO] foo help"
#: ../../library/argparse.rst:208
msgid ""
"The ``%(prog)s`` format specifier is available to fill in the program name "
"in your usage messages."
msgstr "``%(prog)s`` 格式說明符號可用於在你的用法訊息中填入程式名稱。"
#: ../../library/argparse.rst:211
msgid ""
"When a custom usage message is specified for the main parser, you may also "
"want to consider passing the ``prog`` argument to :meth:`~ArgumentParser."
"add_subparsers` or the ``prog`` and the ``usage`` arguments to :meth:"
"`~_SubParsersAction.add_parser`, to ensure consistent command prefixes and "
"usage information across subparsers."
msgstr ""
"當為主剖析器指定了自訂用法訊息時,你可能也會想考慮將 ``prog`` 引數傳給 :meth:"
"`~ArgumentParser.add_subparsers`,或是將 ``prog`` 和 ``usage`` 引數傳給 :"
"meth:`~_SubParsersAction.add_parser` 以確保子剖析器之間的命令前綴和用法資訊一"
"致。"
#: ../../library/argparse.rst:221
msgid "description"
msgstr "description"
#: ../../library/argparse.rst:223
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:229
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 ""
"預設情況下,該描述會被自動斷行來配合給定的空間。若要更改此行為,請參閱 "
"formatter_class_ 引數。"
#: ../../library/argparse.rst:234
msgid "epilog"
msgstr "epilog"
#: ../../library/argparse.rst:236
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 ""
"有些程式喜歡在引數描述之後顯示程式的額外說明。可以使用 :class:"
"`ArgumentParser` 的 ``epilog=`` 引數來指定這類文字: ::"
#: ../../library/argparse.rst:240
msgid ""
">>> parser = argparse.ArgumentParser(\n"
"... description='A foo that bars',\n"
"... epilog=\"And that's how you'd foo a bar\")\n"
">>> parser.print_help()\n"
"usage: argparse.py [-h]\n"
"\n"
"A foo that bars\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
"\n"
"And that's how you'd foo a bar"
msgstr ""
">>> parser = argparse.ArgumentParser(\n"
"... description='A foo that bars',\n"
"... epilog=\"And that's how you'd foo a bar\")\n"
">>> parser.print_help()\n"
"usage: argparse.py [-h]\n"
"\n"
"A foo that bars\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
"\n"
"And that's how you'd foo a bar"
#: ../../library/argparse.rst:253
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=`` 文字預設會被自動斷行,但可以透過 :"
"class:`ArgumentParser` 的 formatter_class_ 引數調整此行為。"
#: ../../library/argparse.rst:259
msgid "parents"
msgstr "parents"
#: ../../library/argparse.rst:261
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 ""
"有時候多個剖析器會共用一組共同的引數。與其重複定義這些引數,不如使用一個包含"
"所有共用引數的剖析器,並將其傳給 :class:`ArgumentParser` 的 ``parents=`` 引"
"數。``parents=`` 引數接受一個 :class:`ArgumentParser` 物件的串列,收集它們的"
"所有位置 action 和可選 action,並將這些 action 加入正在建構的 :class:"
"`ArgumentParser` 物件中: ::"
#: ../../library/argparse.rst:268
msgid ""
">>> parent_parser = argparse.ArgumentParser(add_help=False)\n"
">>> parent_parser.add_argument('--parent', type=int)\n"
"\n"
">>> foo_parser = argparse.ArgumentParser(parents=[parent_parser])\n"
">>> foo_parser.add_argument('foo')\n"
">>> foo_parser.parse_args(['--parent', '2', 'XXX'])\n"
"Namespace(foo='XXX', parent=2)\n"
"\n"
">>> bar_parser = argparse.ArgumentParser(parents=[parent_parser])\n"
">>> bar_parser.add_argument('--bar')\n"
">>> bar_parser.parse_args(['--bar', 'YYY'])\n"
"Namespace(bar='YYY', parent=None)"
msgstr ""
">>> parent_parser = argparse.ArgumentParser(add_help=False)\n"
">>> parent_parser.add_argument('--parent', type=int)\n"
"\n"
">>> foo_parser = argparse.ArgumentParser(parents=[parent_parser])\n"
">>> foo_parser.add_argument('foo')\n"
">>> foo_parser.parse_args(['--parent', '2', 'XXX'])\n"
"Namespace(foo='XXX', parent=2)\n"
"\n"
">>> bar_parser = argparse.ArgumentParser(parents=[parent_parser])\n"
">>> bar_parser.add_argument('--bar')\n"
">>> bar_parser.parse_args(['--bar', 'YYY'])\n"
"Namespace(bar='YYY', parent=None)"
#: ../../library/argparse.rst:281
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:"
"`ArgumentParser` 會看到兩個 ``-h/--help`` 選項(一個在父剖析器中,一個在子剖"
"析器中)並引發錯誤。"
#: ../../library/argparse.rst:286
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:294
msgid "formatter_class"
msgstr "formatter_class"
#: ../../library/argparse.rst:296
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:305
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:310
msgid ""
">>> parser = argparse.ArgumentParser(\n"
"... prog='PROG',\n"
"... description='''this description\n"
"... was indented weird\n"
"... but that is okay''',\n"
"... epilog='''\n"
"... likewise for this epilog whose whitespace will\n"
"... be cleaned up and whose words will be wrapped\n"
"... across a couple lines''')\n"
">>> parser.print_help()\n"
"usage: PROG [-h]\n"
"\n"
"this description was indented weird but that is okay\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
"\n"
"likewise for this epilog whose whitespace will be cleaned up and whose "
"words\n"
"will be wrapped across a couple lines"
msgstr ""
">>> parser = argparse.ArgumentParser(\n"
"... prog='PROG',\n"
"... description='''this description\n"
"... was indented weird\n"
"... but that is okay''',\n"
"... epilog='''\n"
"... likewise for this epilog whose whitespace will\n"
"... be cleaned up and whose words will be wrapped\n"
"... across a couple lines''')\n"
">>> parser.print_help()\n"
"usage: PROG [-h]\n"
"\n"
"this description was indented weird but that is okay\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
"\n"
"likewise for this epilog whose whitespace will be cleaned up and whose "
"words\n"
"will be wrapped across a couple lines"
#: ../../library/argparse.rst:330
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:334
msgid ""
">>> parser = argparse.ArgumentParser(\n"
"... prog='PROG',\n"
"... formatter_class=argparse.RawDescriptionHelpFormatter,\n"
"... description=textwrap.dedent('''\\\n"
"... Please do not mess up this text!\n"
"... --------------------------------\n"
"... I have indented it\n"
"... exactly the way\n"
"... I want it\n"
"... '''))\n"
">>> parser.print_help()\n"
"usage: PROG [-h]\n"
"\n"
"Please do not mess up this text!\n"
"--------------------------------\n"
" I have indented it\n"
" exactly the way\n"
" I want it\n"
"\n"
"options:\n"
" -h, --help show this help message and exit"
msgstr ""
">>> parser = argparse.ArgumentParser(\n"
"... prog='PROG',\n"
"... formatter_class=argparse.RawDescriptionHelpFormatter,\n"
"... description=textwrap.dedent('''\\\n"
"... Please do not mess up this text!\n"
"... --------------------------------\n"
"... I have indented it\n"
"... exactly the way\n"
"... I want it\n"
"... '''))\n"
">>> parser.print_help()\n"
"usage: PROG [-h]\n"
"\n"
"Please do not mess up this text!\n"
"--------------------------------\n"
" I have indented it\n"
" exactly the way\n"
" I want it\n"
"\n"
"options:\n"
" -h, --help show this help message and exit"
#: ../../library/argparse.rst:356
msgid ""
":class:`RawTextHelpFormatter` maintains whitespace for all sorts of help "
"text, including argument descriptions. However, multiple newlines are "
"replaced with one. If you wish to preserve multiple blank lines, add spaces "
"between the newlines."
msgstr ""
":class:`RawTextHelpFormatter` 會為所有種類的說明文字保留空白,包括引數描述。"
"然而多個換行符號會被替換為一個。如果你希望保留多個空白行,請在換行符號之間加"
"入空格。"
#: ../../library/argparse.rst:361
msgid ""
":class:`ArgumentDefaultsHelpFormatter` automatically adds information about "
"default values to each of the argument help messages::"
msgstr ""
":class:`ArgumentDefaultsHelpFormatter` 會自動將預設值的資訊加入每個引數的說明"
"訊息中: ::"
#: ../../library/argparse.rst:364
msgid ""
">>> parser = argparse.ArgumentParser(\n"
"... prog='PROG',\n"
"... formatter_class=argparse.ArgumentDefaultsHelpFormatter)\n"
">>> parser.add_argument('--foo', type=int, default=42, help='FOO!')\n"
">>> parser.add_argument('bar', nargs='*', default=[1, 2, 3], help='BAR!')\n"
">>> parser.print_help()\n"
"usage: PROG [-h] [--foo FOO] [bar ...]\n"
"\n"
"positional arguments:\n"
" bar BAR! (default: [1, 2, 3])\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --foo FOO FOO! (default: 42)"
msgstr ""
">>> parser = argparse.ArgumentParser(\n"
"... prog='PROG',\n"
"... formatter_class=argparse.ArgumentDefaultsHelpFormatter)\n"
">>> parser.add_argument('--foo', type=int, default=42, help='FOO!')\n"
">>> parser.add_argument('bar', nargs='*', default=[1, 2, 3], help='BAR!')\n"
">>> parser.print_help()\n"
"usage: PROG [-h] [--foo FOO] [bar ...]\n"
"\n"
"positional arguments:\n"
" bar BAR! (default: [1, 2, 3])\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --foo FOO FOO! (default: 42)"
#: ../../library/argparse.rst:379
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:383
msgid ""
">>> parser = argparse.ArgumentParser(\n"
"... prog='PROG',\n"
"... formatter_class=argparse.MetavarTypeHelpFormatter)\n"
">>> parser.add_argument('--foo', type=int)\n"
">>> parser.add_argument('bar', type=float)\n"
">>> parser.print_help()\n"
"usage: PROG [-h] [--foo int] float\n"
"\n"
"positional arguments:\n"
" float\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --foo int"
msgstr ""
">>> parser = argparse.ArgumentParser(\n"
"... prog='PROG',\n"
"... formatter_class=argparse.MetavarTypeHelpFormatter)\n"
">>> parser.add_argument('--foo', type=int)\n"
">>> parser.add_argument('bar', type=float)\n"
">>> parser.print_help()\n"
"usage: PROG [-h] [--foo int] float\n"
"\n"
"positional arguments:\n"
" float\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --foo int"
#: ../../library/argparse.rst:400
msgid "prefix_chars"
msgstr "prefix_chars"
#: ../../library/argparse.rst:402
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 :class:`ArgumentParser` constructor::"
msgstr ""
"大多數命令列選項會使用 ``-`` 作為前綴,例如 ``-f/--foo``。需要支援不同或額外"
"前綴字元的剖析器,例如 ``+f`` 或 ``/foo`` 之類的選項,可以使用 :class:"
"`ArgumentParser` 建構函式的 ``prefix_chars=`` 引數來指定: ::"
#: ../../library/argparse.rst:408
msgid ""
">>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='-+')\n"
">>> parser.add_argument('+f')\n"
">>> parser.add_argument('++bar')\n"
">>> parser.parse_args('+f X ++bar Y'.split())\n"
"Namespace(bar='Y', f='X')"
msgstr ""
">>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='-+')\n"
">>> parser.add_argument('+f')\n"
">>> parser.add_argument('++bar')\n"
">>> parser.parse_args('+f X ++bar Y'.split())\n"
"Namespace(bar='Y', f='X')"
#: ../../library/argparse.rst:414
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:420
msgid "fromfile_prefix_chars"
msgstr "fromfile_prefix_chars"
#: ../../library/argparse.rst:422
msgid ""
"Sometimes, 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:429
msgid ""
">>> with open('args.txt', 'w', encoding=sys.getfilesystemencoding()) as fp:\n"
"... fp.write('-f\\nbar')\n"
"...\n"
">>> parser = argparse.ArgumentParser(fromfile_prefix_chars='@')\n"
">>> parser.add_argument('-f')\n"
">>> parser.parse_args(['-f', 'foo', '@args.txt'])\n"
"Namespace(f='bar')"
msgstr ""
">>> with open('args.txt', 'w', encoding=sys.getfilesystemencoding()) as fp:\n"
"... fp.write('-f\\nbar')\n"
"...\n"
">>> parser = argparse.ArgumentParser(fromfile_prefix_chars='@')\n"
">>> parser.add_argument('-f')\n"
">>> parser.parse_args(['-f', 'foo', '@args.txt'])\n"
"Namespace(f='bar')"
#: ../../library/argparse.rst:437
msgid ""
"Arguments read from a file must be one per line by default (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:445
msgid ""
"Empty lines are treated as empty strings (``''``), which are allowed as "
"values but not as arguments. Empty lines that are read as arguments will "
"result in an \"unrecognized arguments\" error."
msgstr ""
"空行會被視為空字串 (``''``),可以作為值但不能作為引數。若空行被讀取為引數,會"
"導致 \"unrecognized arguments\" 錯誤。"
#: ../../library/argparse.rst:449
msgid ""
":class:`ArgumentParser` uses :term:`filesystem encoding and error handler` "
"to read the file containing arguments."
msgstr ""
":class:`ArgumentParser` 使用\\ :term:`檔案系統編碼和錯誤處理函式 <filesystem "
"encoding and error handler>`\\ 來讀取包含引數的檔案。"
#: ../../library/argparse.rst:452
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:455
msgid ""
":class:`ArgumentParser` changed encoding and errors to read arguments files "
"from default (e.g. :func:`locale.getpreferredencoding(False) <locale."
"getpreferredencoding>` and ``\"strict\"``) to the :term:`filesystem encoding "
"and error handler`. Arguments file should be encoded in UTF-8 instead of "
"ANSI Codepage on Windows."
msgstr ""
":class:`ArgumentParser` 將讀取引數檔案的編碼和錯誤處理從預設值(例如 :func:"
"`locale.getpreferredencoding(False) <locale.getpreferredencoding>` 和 "
"``\"strict\"``)改為\\ :term:`檔案系統編碼和錯誤處理函式 <filesystem "
"encoding and error handler>`。在 Windows 上引數檔案應使用 UTF-8 而非 ANSI 字"
"碼頁編碼。"
#: ../../library/argparse.rst:463
msgid "argument_default"
msgstr "argument_default"
#: ../../library/argparse.rst:465
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` 方法並指定一"
"組名稱—值對 (name-value pair) 來設定。然而有時候為引數指定一個剖析器層級的單"
"一預設值可能很有用。這可以透過將 ``argument_default=`` 關鍵字引數傳給 :class:"
"`ArgumentParser` 來完成。例如若要全域地抑制 :meth:`~ArgumentParser."
"parse_args` 呼叫時的屬性建立,我們可以提供 ``argument_default=SUPPRESS``: ::"
#: ../../library/argparse.rst:474
msgid ""
">>> parser = argparse.ArgumentParser(argument_default=argparse.SUPPRESS)\n"
">>> parser.add_argument('--foo')\n"
">>> parser.add_argument('bar', nargs='?')\n"
">>> parser.parse_args(['--foo', '1', 'BAR'])\n"
"Namespace(bar='BAR', foo='1')\n"
">>> parser.parse_args([])\n"
"Namespace()"
msgstr ""
">>> parser = argparse.ArgumentParser(argument_default=argparse.SUPPRESS)\n"
">>> parser.add_argument('--foo')\n"
">>> parser.add_argument('bar', nargs='?')\n"
">>> parser.parse_args(['--foo', '1', 'BAR'])\n"
"Namespace(bar='BAR', foo='1')\n"
">>> parser.parse_args([])\n"
"Namespace()"
#: ../../library/argparse.rst:485
msgid "allow_abbrev"
msgstr "allow_abbrev"
#: ../../library/argparse.rst:487
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:`辨識為長選項的縮寫 <prefix-"
"matching>`。"
#: ../../library/argparse.rst:491
msgid "This feature can be disabled by setting ``allow_abbrev`` to ``False``::"
msgstr "可以透過將 ``allow_abbrev`` 設為 ``False`` 來停用此功能: ::"
#: ../../library/argparse.rst:493
msgid ""
">>> parser = argparse.ArgumentParser(prog='PROG', allow_abbrev=False)\n"
">>> parser.add_argument('--foobar', action='store_true')\n"
">>> parser.add_argument('--foonley', action='store_false')\n"
">>> parser.parse_args(['--foon'])\n"
"usage: PROG [-h] [--foobar] [--foonley]\n"
"PROG: error: unrecognized arguments: --foon"
msgstr ""
">>> parser = argparse.ArgumentParser(prog='PROG', allow_abbrev=False)\n"
">>> parser.add_argument('--foobar', action='store_true')\n"
">>> parser.add_argument('--foonley', action='store_false')\n"
">>> parser.parse_args(['--foon'])\n"
"usage: PROG [-h] [--foobar] [--foonley]\n"
"PROG: error: unrecognized arguments: --foon"
#: ../../library/argparse.rst:504
msgid "conflict_handler"
msgstr "conflict_handler"
#: ../../library/argparse.rst:506
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 ""