@@ -12,7 +12,7 @@ msgid ""
12
12
msgstr ""
13
13
"Project-Id-Version : Python 3.13\n "
14
14
"Report-Msgid-Bugs-To : \n "
15
- "POT-Creation-Date : 2025-05-16 14:58 +0000\n "
15
+ "POT-Creation-Date : 2025-06-06 14:57 +0000\n "
16
16
"PO-Revision-Date : 2025-05-08 05:09+0000\n "
17
17
"Last-Translator : Freesand Leo <yuqinju@163.com>, 2025\n "
18
18
"Language-Team : Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n "
@@ -3795,20 +3795,21 @@ msgstr "部分解析"
3795
3795
3796
3796
#: ../../library/argparse.rst:2016
3797
3797
msgid ""
3798
- "Sometimes a script may only parse a few of the command-line arguments, "
3799
- "passing the remaining arguments on to another script or program. In these "
3800
- "cases, the :meth:`~ArgumentParser.parse_known_args` method can be useful. "
3801
- "It works much like :meth:`~ArgumentParser.parse_args` except that it does "
3802
- "not produce an error when extra arguments are present. Instead, it returns "
3803
- "a two item tuple containing the populated namespace and the list of "
3804
- "remaining argument strings."
3798
+ "Sometimes a script only needs to handle a specific set of command-line "
3799
+ "arguments, leaving any unrecognized arguments for another script or program."
3800
+ " In these cases, the :meth:`~ArgumentParser.parse_known_args` method can be "
3801
+ "useful."
3805
3802
msgstr ""
3806
- "有时一个脚本可能只解析部分命令行参数,而将其余的参数继续传递给另一个脚本或程序。 "
3807
- "在这种情况下,:meth:`~ArgumentParser.parse_known_args` 方法会很有用处。 它的作用方式很类似 "
3808
- ":meth:`~ArgumentParser.parse_args` 但区别在于当存在额外参数时它不会产生错误。 "
3809
- "而是会返回一个由两个条目构成的元组,其中包含带成员的命名空间和剩余参数字符串的列表。"
3810
3803
3811
- #: ../../library/argparse.rst:2025
3804
+ #: ../../library/argparse.rst:2021
3805
+ msgid ""
3806
+ "This method works similarly to :meth:`~ArgumentParser.parse_args`, but it "
3807
+ "does not raise an error for extra, unrecognized arguments. Instead, it "
3808
+ "parses the known arguments and returns a two item tuple that contains the "
3809
+ "populated namespace and the list of any unrecognized arguments."
3810
+ msgstr ""
3811
+
3812
+ #: ../../library/argparse.rst:2028
3812
3813
msgid ""
3813
3814
">>> parser = argparse.ArgumentParser()\n"
3814
3815
">>> parser.add_argument('--foo', action='store_true')\n"
@@ -3822,7 +3823,7 @@ msgstr ""
3822
3823
">>> parser.parse_known_args(['--foo', '--badger', 'BAR', 'spam'])\n"
3823
3824
"(Namespace(bar='BAR', foo=True), ['--badger', 'spam'])"
3824
3825
3825
- #: ../../library/argparse.rst:2032
3826
+ #: ../../library/argparse.rst:2035
3826
3827
msgid ""
3827
3828
":ref:`Prefix matching <prefix-matching>` rules apply to "
3828
3829
":meth:`~ArgumentParser.parse_known_args`. The parser may consume an option "
@@ -3833,11 +3834,11 @@ msgstr ""
3833
3834
":meth:`~ArgumentParser.parse_known_args`。 "
3834
3835
"一个解析器即使在某个选项只是已知选项的前缀时也能读取该选项,而不是将其放入剩余参数列表。"
3835
3836
3836
- #: ../../library/argparse.rst:2039
3837
+ #: ../../library/argparse.rst:2042
3837
3838
msgid "Customizing file parsing"
3838
3839
msgstr "自定义文件解析"
3839
3840
3840
- #: ../../library/argparse.rst:2043
3841
+ #: ../../library/argparse.rst:2046
3841
3842
msgid ""
3842
3843
"Arguments that are read from a file (see the *fromfile_prefix_chars* keyword"
3843
3844
" argument to the :class:`ArgumentParser` constructor) are read one argument "
@@ -3847,7 +3848,7 @@ msgstr ""
3847
3848
"从文件读取的参数(见 :class:`ArgumentParser` 的 *fromfile_prefix_chars* "
3848
3849
"关键字参数)将是一行读取一个参数。 :meth:`convert_arg_line_to_args` 可被重写以使用更复杂的读取方式。"
3849
3850
3850
- #: ../../library/argparse.rst:2048
3851
+ #: ../../library/argparse.rst:2051
3851
3852
msgid ""
3852
3853
"This method takes a single argument *arg_line* which is a string read from "
3853
3854
"the argument file. It returns a list of arguments parsed from this string. "
@@ -3856,13 +3857,13 @@ msgstr ""
3856
3857
"此方法接受从参数文件读取的字符串形式的单个参数 *arg_line*。 它返回从该字符串解析出的参数列表。 "
3857
3858
"此方法将在每次按顺序从参数文件读取一行时被调用一次。"
3858
3859
3859
- #: ../../library/argparse.rst:2052
3860
+ #: ../../library/argparse.rst:2055
3860
3861
msgid ""
3861
3862
"A useful override of this method is one that treats each space-separated "
3862
3863
"word as an argument. The following example demonstrates how to do this::"
3863
3864
msgstr "此方法的一个有用的重写是将每个以空格分隔的单词视为一个参数。 下面的例子演示了如何实现这一点::"
3864
3865
3865
- #: ../../library/argparse.rst:2055
3866
+ #: ../../library/argparse.rst:2058
3866
3867
msgid ""
3867
3868
"class MyArgumentParser(argparse.ArgumentParser):\n"
3868
3869
" def convert_arg_line_to_args(self, arg_line):\n"
@@ -3872,11 +3873,11 @@ msgstr ""
3872
3873
" def convert_arg_line_to_args(self, arg_line):\n"
3873
3874
" return arg_line.split()"
3874
3875
3875
- #: ../../library/argparse.rst:2061
3876
+ #: ../../library/argparse.rst:2064
3876
3877
msgid "Exiting methods"
3877
3878
msgstr "退出方法"
3878
3879
3879
- #: ../../library/argparse.rst:2065
3880
+ #: ../../library/argparse.rst:2068
3880
3881
msgid ""
3881
3882
"This method terminates the program, exiting with the specified *status* and,"
3882
3883
" if given, it prints a *message* to :data:`sys.stderr` before that. The user"
@@ -3885,7 +3886,7 @@ msgstr ""
3885
3886
"此方法将终结程序,退出时附带指定的 *status*,并且如果给出了 *message* 则会在退出前将其打印到 :data:`sys.stderr`。"
3886
3887
" 用户可重写此方法以不同方式来处理这些步骤::"
3887
3888
3888
- #: ../../library/argparse.rst:2069
3889
+ #: ../../library/argparse.rst:2072
3889
3890
msgid ""
3890
3891
"class ErrorCatchingArgumentParser(argparse.ArgumentParser):\n"
3891
3892
" def exit(self, status=0, message=None):\n"
@@ -3899,17 +3900,17 @@ msgstr ""
3899
3900
" raise Exception(f'Exiting because of an error: {message}')\n"
3900
3901
" exit(status)"
3901
3902
3902
- #: ../../library/argparse.rst:2077
3903
+ #: ../../library/argparse.rst:2080
3903
3904
msgid ""
3904
3905
"This method prints a usage message, including the *message*, to "
3905
3906
":data:`sys.stderr` and terminates the program with a status code of 2."
3906
3907
msgstr "此方法将把用法消息包括 *message* 打印到 :data:`sys.stderr` 并附带状态码 2 终结程序。"
3907
3908
3908
- #: ../../library/argparse.rst:2082
3909
+ #: ../../library/argparse.rst:2085
3909
3910
msgid "Intermixed parsing"
3910
3911
msgstr "混合解析"
3911
3912
3912
- #: ../../library/argparse.rst:2087
3913
+ #: ../../library/argparse.rst:2090
3913
3914
msgid ""
3914
3915
"A number of Unix commands allow the user to intermix optional arguments with"
3915
3916
" positional arguments. The :meth:`~ArgumentParser.parse_intermixed_args` "
@@ -3919,7 +3920,7 @@ msgstr ""
3919
3920
"许多 Unix 命令允许用户混用可选参数与位置参数。 :meth:`~ArgumentParser.parse_intermixed_args` 和 "
3920
3921
":meth:`~ArgumentParser.parse_known_intermixed_args` 方法均支持这种解析风格。"
3921
3922
3922
- #: ../../library/argparse.rst:2092
3923
+ #: ../../library/argparse.rst:2095
3923
3924
msgid ""
3924
3925
"These parsers do not support all the :mod:`!argparse` features, and will "
3925
3926
"raise exceptions if unsupported features are used. In particular, "
@@ -3929,7 +3930,7 @@ msgstr ""
3929
3930
"这些解析器并不支持所有的 :mod:`!argparse` 特性,并且当不受支持的特性被使用时将会引发异常。 "
3930
3931
"具体来说,子解析器以及同时包括可选参数和位置参数的互斥分组是不受支持的。"
3931
3932
3932
- #: ../../library/argparse.rst:2097
3933
+ #: ../../library/argparse.rst:2100
3933
3934
msgid ""
3934
3935
"The following example shows the difference between "
3935
3936
":meth:`~ArgumentParser.parse_known_args` and "
@@ -3941,7 +3942,7 @@ msgstr ""
3941
3942
":meth:`~ArgumentParser.parse_intermixed_args` 之间的差异:前者会将 ``['2', '3']`` "
3942
3943
"返回为未解析的参数,而后者会将所有位置参数收集至 ``rest`` 中。 ::"
3943
3944
3944
- #: ../../library/argparse.rst:2103
3945
+ #: ../../library/argparse.rst:2106
3945
3946
msgid ""
3946
3947
">>> parser = argparse.ArgumentParser()\n"
3947
3948
">>> parser.add_argument('--foo')\n"
@@ -3961,7 +3962,7 @@ msgstr ""
3961
3962
">>> parser.parse_intermixed_args('doit 1 --foo bar 2 3'.split())\n"
3962
3963
"Namespace(cmd='doit', foo='bar', rest=[1, 2, 3])"
3963
3964
3964
- #: ../../library/argparse.rst:2112
3965
+ #: ../../library/argparse.rst:2115
3965
3966
msgid ""
3966
3967
":meth:`~ArgumentParser.parse_known_intermixed_args` returns a two item tuple"
3967
3968
" containing the populated namespace and the list of remaining argument "
@@ -3972,11 +3973,11 @@ msgstr ""
3972
3973
"返回由两个条目组成的元组,其中包含带成员的命名空间以及剩余参数字符串列表。 当存在任何剩余的未解析参数字符串时 "
3973
3974
":meth:`~ArgumentParser.parse_intermixed_args` 将引发一个错误。"
3974
3975
3975
- #: ../../library/argparse.rst:2121
3976
+ #: ../../library/argparse.rst:2124
3976
3977
msgid "Registering custom types or actions"
3977
3978
msgstr "注册自定义的类型或动作"
3978
3979
3979
- #: ../../library/argparse.rst:2125
3980
+ #: ../../library/argparse.rst:2128
3980
3981
msgid ""
3981
3982
"Sometimes it's desirable to use a custom string in error messages to provide"
3982
3983
" more user-friendly output. In these cases, :meth:`!register` can be used to"
@@ -3986,7 +3987,7 @@ msgstr ""
3986
3987
"在某些时候有必要在错误消息中使用自定义的字符串以提供对用户更友好的输出。 在这种情况下,可以使用 :meth:`!register` "
3987
3988
"来注册带有解析器的自定义动作或类型并允许你按其注册名称而非其可调用对象名称来引用该类型。"
3988
3989
3989
- #: ../../library/argparse.rst:2130
3990
+ #: ../../library/argparse.rst:2133
3990
3991
msgid ""
3991
3992
"The :meth:`!register` method accepts three arguments - a *registry_name*, "
3992
3993
"specifying the internal registry where the object will be stored (e.g., "
@@ -3996,12 +3997,12 @@ msgstr ""
3996
3997
":meth:`!register` 方法接受三个参数 —— *registry_name*,指定将要存储对象的内部注册表 (例如 ``action``,"
3997
3998
" ``type``),*value*,将要注册对象对应的键,以及 object,将要注册的可调用对象。"
3998
3999
3999
- #: ../../library/argparse.rst:2135
4000
+ #: ../../library/argparse.rst:2138
4000
4001
msgid ""
4001
4002
"The following example shows how to register a custom type with a parser::"
4002
4003
msgstr "下面的例子演示了如何注册一个带解析器的自定义类型::"
4003
4004
4004
- #: ../../library/argparse.rst:2137
4005
+ #: ../../library/argparse.rst:2140
4005
4006
msgid ""
4006
4007
">>> import argparse\n"
4007
4008
">>> parser = argparse.ArgumentParser()\n"
@@ -4025,26 +4026,26 @@ msgstr ""
4025
4026
"usage: PROG [-h] [--foo FOO]\n"
4026
4027
"PROG: error: argument --foo: invalid 'hexadecimal integer' value: '1.2'"
4027
4028
4028
- #: ../../library/argparse.rst:2149
4029
+ #: ../../library/argparse.rst:2152
4029
4030
msgid "Exceptions"
4030
4031
msgstr "异常"
4031
4032
4032
- #: ../../library/argparse.rst:2153
4033
+ #: ../../library/argparse.rst:2156
4033
4034
msgid "An error from creating or using an argument (optional or positional)."
4034
4035
msgstr "来自创建或使用某个参数的消息(可选或位置参数)。"
4035
4036
4036
- #: ../../library/argparse.rst:2155
4037
+ #: ../../library/argparse.rst:2158
4037
4038
msgid ""
4038
4039
"The string value of this exception is the message, augmented with "
4039
4040
"information about the argument that caused it."
4040
4041
msgstr "此异常的字符串值即异常消息,并附带有导致该异常的参数的相关信息。"
4041
4042
4042
- #: ../../library/argparse.rst:2160
4043
+ #: ../../library/argparse.rst:2163
4043
4044
msgid ""
4044
4045
"Raised when something goes wrong converting a command line string to a type."
4045
4046
msgstr "当从一个命令行字符串到特定类型的转换出现问题时引发。"
4046
4047
4047
- #: ../../library/argparse.rst:2164
4048
+ #: ../../library/argparse.rst:2167
4048
4049
msgid "Guides and Tutorials"
4049
4050
msgstr "指南与教程"
4050
4051
0 commit comments