@@ -2991,6 +2991,12 @@ msgid ""
2991
2991
" and returns an :class:`!ArgumentParser` object that can be modified as "
2992
2992
"usual."
2993
2993
msgstr ""
2994
+ "许多程序都将其功能拆分为一系列子命令,例如,``svn`` 程序可唤起像 ``svn checkout``, ``svn update`` 和 "
2995
+ "``svn commit`` 等子命令。 当一个程序执行需要多组不同各类命令行参数时这种拆分功能的方式是一个非常好的主意。 "
2996
+ ":class:`ArgumentParser` 通过 :meth:`!add_subparsers` 方法支持创建这样的子命令。 "
2997
+ ":meth:`!add_subparsers` 方法通常不带参数地调用并返回一个特殊的动作对象。 该对象只有一个方法 "
2998
+ ":meth:`~_SubParsersAction.add_parser`,它接受一个命令名称和任意多个 "
2999
+ ":class:`!ArgumentParser` 构造器参数,并返回一个可以通常方式进行修改的 :class:`!ArgumentParser` 对象。"
2994
3000
2995
3001
#: ../../library/argparse.rst:1582
2996
3002
msgid "Description of parameters:"
@@ -3014,13 +3020,14 @@ msgid ""
3014
3020
"*prog* - usage information that will be displayed with sub-command help, by "
3015
3021
"default the name of the program and any positional arguments before the "
3016
3022
"subparser argument"
3017
- msgstr ""
3023
+ msgstr "*prog* - 将与子命令帮助一同显示的用法信息,默认为程序名称和子解析器参数之前的任何位置参数 "
3018
3024
3019
3025
#: ../../library/argparse.rst:1595
3020
3026
msgid ""
3021
3027
"*parser_class* - class which will be used to create sub-parser instances, by"
3022
3028
" default the class of the current parser (e.g. :class:`ArgumentParser`)"
3023
3029
msgstr ""
3030
+ "*parser_class* - 将被用于创建子解析器实例的类,默认为当前解析器类 (例如 :class:`ArgumentParser`)"
3024
3031
3025
3032
#: ../../library/argparse.rst:1598
3026
3033
msgid ""
@@ -3048,7 +3055,7 @@ msgstr "help_ - 在输出帮助中的子解析器分组帮助信息,默认为
3048
3055
msgid ""
3049
3056
"metavar_ - string presenting available subcommands in help; by default it is"
3050
3057
" ``None`` and presents subcommands in form {cmd1, cmd2, ..}"
3051
- msgstr ""
3058
+ msgstr "metavar_ - 帮助信息中表示可用子命令的字符串;默认为 ``None`` 并以 {cmd1, cmd2, ..} 的形式表示子命令 "
3052
3059
3053
3060
#: ../../library/argparse.rst:1612
3054
3061
msgid "Some example usage::"
@@ -3262,6 +3269,8 @@ msgid ""
3262
3269
"that each subparser knows which Python function it should execute. For "
3263
3270
"example::"
3264
3271
msgstr ""
3272
+ "一个特别有效的处理子命令的方式是将 :meth:`add_subparsers` 方法与对 :meth:`set_defaults` "
3273
+ "的调用结合起来使用以便每个子解析器能知道应当执行哪个 Python 函数。 例如::"
3265
3274
3266
3275
#: ../../library/argparse.rst:1728
3267
3276
msgid ""
@@ -3433,6 +3442,8 @@ msgid ""
3433
3442
"appropriate groups can be created using the :meth:`!add_argument_group` "
3434
3443
"method::"
3435
3444
msgstr ""
3445
+ "在默认情况下,:class:`ArgumentParser` 会在显示帮助消息时将命令行参数分为“位置参数”和“选项”两组。 "
3446
+ "当存在比默认更好的分组概念时,可以使用 :meth:`!add_argument_group` 方法来创建适当的分组::"
3436
3447
3437
3448
#: ../../library/argparse.rst:1822
3438
3449
msgid ""
@@ -3980,6 +3991,8 @@ msgid ""
3980
3991
"``action``, ``type``), *value*, which is the key under which the object will"
3981
3992
" be registered, and object, the callable to be registered."
3982
3993
msgstr ""
3994
+ ":meth:`!register` 方法接受三个参数 —— *registry_name*,指定将要存储对象的内部注册表 (例如 ``action``,"
3995
+ " ``type``),*value*,将要注册对象对应的键,以及 object,将要注册的可调用对象。"
3983
3996
3984
3997
#: ../../library/argparse.rst:2135
3985
3998
msgid ""
0 commit comments