@@ -727,6 +727,8 @@ msgid ""
727
727
"for options like ``+f`` or ``/foo``, may specify them using the "
728
728
"``prefix_chars=`` argument to the :class:`ArgumentParser` constructor::"
729
729
msgstr ""
730
+ "大部分命令列選項會用 ``-`` 做為其前綴,例如 ``-f/--foo``。"
731
+ "如果你預期你的剖析器需要支援例如 ``+f`` 或 ``/foo`` 等其他的前綴,你可以在 :class:`ArgumentParser` 的建構時用 ``prefix_chars=`` 來指定,如下例:::"
730
732
731
733
#: ../../library/argparse.rst:377
732
734
msgid ""
@@ -748,6 +750,7 @@ msgid ""
748
750
"characters that does not include ``-`` will cause ``-f/--foo`` options to be "
749
751
"disallowed."
750
752
msgstr ""
753
+ "``prefix_chars=`` 的預設值是 ``'-'``。如果你提供的字元集合裡面不包含 ``-`` 的話,會使得該前綴 ``-f/--foo`` 不再有效。"
751
754
752
755
#: ../../library/argparse.rst:389
753
756
msgid "fromfile_prefix_chars"
@@ -762,6 +765,9 @@ msgid ""
762
765
"of the specified characters will be treated as files, and will be replaced "
763
766
"by the arguments they contain. For example::"
764
767
msgstr ""
768
+ "有時候,某些程式呼叫時需要的引數可能非常冗長,這時候將其全數儲存在一個文字檔案裡可能會比每次都重打一遍要方便得多。"
769
+ "如果在建構 :class:`ArgumentParser` 時有指定 ``fromfile_prefix_chars=`` 的字元集合,則任何使用該系列字元開頭的選項字串都會被視作為檔案,並以其中儲存的引數取代其位置。"
770
+ "請見下例:::"
765
771
766
772
#: ../../library/argparse.rst:398
767
773
msgid ""
@@ -790,18 +796,24 @@ msgid ""
790
796
"'@args.txt']`` is considered equivalent to the expression ``['-f', 'foo', '-"
791
797
"f', 'bar']``."
792
798
msgstr ""
799
+ "從檔案讀取引數時,預設每行只會有一個選項(詳情請參見 :meth:`~ArgumentParser.convert_arg_line_to_args`),"
800
+ "且這些選項的位置會取代原先指定檔案時該選項的位置。以上例而言,``['-f', 'foo', "
801
+ "'@args.txt']`` 等於是 ``['-f', 'foo', '-"
802
+ "f', 'bar']``。"
793
803
794
804
#: ../../library/argparse.rst:412
795
805
msgid ""
796
806
":class:`ArgumentParser` uses :term:`filesystem encoding and error handler` "
797
807
"to read the file containing arguments."
798
808
msgstr ""
809
+ ":class:`ArgumentParser` 使用 :term:`filesystem encoding and error handler` 來讀取含有引數的檔案。"
799
810
800
811
#: ../../library/argparse.rst:415
801
812
msgid ""
802
813
"The ``fromfile_prefix_chars=`` argument defaults to ``None``, meaning that "
803
814
"arguments will never be treated as file references."
804
815
msgstr ""
816
+ "``fromfile_prefix_chars=`` 預設是沒有值得,也就是預設行為中不存在令選項被視為檔案處理的前綴。"
805
817
806
818
#: ../../library/argparse.rst:418
807
819
msgid ""
@@ -811,6 +823,9 @@ msgid ""
811
823
"and error handler`. Arguments file should be encoded in UTF-8 instead of "
812
824
"ANSI Codepage on Windows."
813
825
msgstr ""
826
+ ":class:`ArgumentParser` 讀取檔案的行為從預設(:func:`locale.getpreferredencoding(False) <locale."
827
+ "getpreferredencoding>` and ``\" strict\" ``)改成 :term:`filesystem encoding "
828
+ "and error handler`。因此在 Windows 作業系統上,引數檔案應該以 UTF-8 編碼儲存,而非 ANSI。"
814
829
815
830
#: ../../library/argparse.rst:426
816
831
msgid "argument_default"
@@ -827,6 +842,11 @@ msgid ""
827
842
"suppress attribute creation on :meth:`~ArgumentParser.parse_args` calls, we "
828
843
"supply ``argument_default=SUPPRESS``::"
829
844
msgstr ""
845
+ "一般來說,引數的預設值會透過在 :"
846
+ "meth:`~ArgumentParser.add_argument` 中寫明或以特定的鍵值對呼叫 :meth:`~ArgumentParser."
847
+ "set_defaults` 來設定預設值。不過,有時候直接設定一個所有選項通用的預設值可能會更方便,"
848
+ "你可以透過在建構 :class:`ArgumentParser` 時將通用預設值傳入 ``argument_default=`` 來達成這個目標。"
849
+ "舉例來說,如果你希望不要在呼叫 :meth:`~ArgumentParser.parse_args` 時就為了每個引數建立一個對應的屬性,你可以傳入 ``argument_default=SUPPRESS``,如下例:::"
830
850
831
851
#: ../../library/argparse.rst:437
832
852
msgid ""
@@ -856,10 +876,12 @@ msgid ""
856
876
"parse_args` method of an :class:`ArgumentParser`, it :ref:`recognizes "
857
877
"abbreviations <prefix-matching>` of long options."
858
878
msgstr ""
879
+ "一般來說,當你將一系列引數傳給 :class:`ArgumentParser` 的 :meth:`~ArgumentParser.parse_args` 方法時"
880
+ ",他能夠 :ref:`認出 <prefix-matching>` 較長選項的縮寫。"
859
881
860
882
#: ../../library/argparse.rst:454
861
883
msgid "This feature can be disabled by setting ``allow_abbrev`` to ``False``::"
862
- msgstr ""
884
+ msgstr "這個功能可以透過將 ``allow_abbrev`` 設為 ``False`` 來關閉::: "
863
885
864
886
#: ../../library/argparse.rst:456
865
887
msgid ""
@@ -888,6 +910,8 @@ msgid ""
888
910
"exception if an attempt is made to create an argument with an option string "
889
911
"that is already in use::"
890
912
msgstr ""
913
+ ":class:`ArgumentParser` 物件不允許針對同一個選項採取兩種動作。"
914
+ ":class:`ArgumentParser` 預設會在針對同一段選項文字發生二次處理時拋出一個例外:::"
891
915
892
916
#: ../../library/argparse.rst:474
893
917
msgid ""
@@ -912,6 +936,8 @@ msgid ""
912
936
"value ``'resolve'`` can be supplied to the ``conflict_handler=`` argument "
913
937
"of :class:`ArgumentParser`::"
914
938
msgstr ""
939
+ "但有時候你可能會希望比較新的選項處裡結果能夠直接覆蓋掉比較舊的(例如使用 parents_ 時)。"
940
+ "在建構 :class:`ArgumentParser` 時指定 ``conflict_handler=`` 為 ``'resolve'`` 就可以啟用這個行為。"
915
941
916
942
#: ../../library/argparse.rst:486
917
943
msgid ""
@@ -946,6 +972,8 @@ msgid ""
946
972
"foo`` action is retained as the ``-f`` action, because only the ``--foo`` "
947
973
"option string was overridden."
948
974
msgstr ""
975
+ ":class:`ArgumentParser` 此時只會停止剖析被完全複寫的選項。"
976
+ "以上例而言,舊有的 ``-f/--foo`` 選項仍會被以 ``-f`` 之名保存,因為只有 ``--foo`` 選項字串被覆寫了。"
949
977
950
978
#: ../../library/argparse.rst:504
951
979
msgid "add_help"
@@ -957,13 +985,17 @@ msgid ""
957
985
"displays the parser's help message. If ``-h`` or ``--help`` is supplied at "
958
986
"the command line, the :class:`!ArgumentParser` help will be printed."
959
987
msgstr ""
988
+ ":class:`ArgumentParser` 預設會自動加入一個能夠印出整個幫助訊息的選項。"
989
+ "如果在呼叫該程式時加入了 ``-h`` 或 ``--help``,則會印出 :class:`!ArgumentParser` 幫助字串。"
960
990
961
991
#: ../../library/argparse.rst:510
962
992
msgid ""
963
993
"Occasionally, it may be useful to disable the addition of this help option. "
964
994
"This can be achieved by passing ``False`` as the ``add_help=`` argument to :"
965
995
"class:`ArgumentParser`::"
966
996
msgstr ""
997
+ "偶爾你可能會遇到需要把這個自動加入幫助選項的行為關掉的情況。"
998
+ "這個行為可以透過在建構 :class:`ArgumentParser` 時將 ``add_help=`` 設為 ``False`` 來達成"
967
999
968
1000
#: ../../library/argparse.rst:514
969
1001
msgid ""
0 commit comments