@@ -1020,12 +1020,15 @@ msgid ""
10201020"``errors=`` arguments of the :func:`open` function. For example, "
10211021"``FileType('w')`` can be used to create a writable file::"
10221022msgstr ""
1023+ "为方便使用不同类型的文件,argparse 模块提供了 FileType 工厂类,该类接受 ``mode=``, ``bufsize=``, "
1024+ "``encoding=`` 和 ``errors=`` 等 :func:`open` 函数参数。 例如,``FileType('w')`` "
1025+ "可被用来创建一个可写文件::"
10231026
10241027#: ../../library/argparse.rst:1046
10251028msgid ""
10261029"``type=`` can take any callable that takes a single string argument and "
10271030"returns the converted value::"
1028- msgstr ""
1031+ msgstr "``type=`` 可接受任意可调用对象,该对象应传入单个字符串参数并返回转换后的值:: "
10291032
10301033#: ../../library/argparse.rst:1065
10311034msgid ""
@@ -1049,19 +1052,25 @@ msgid ""
10491052"line is parsed, argument values will be checked, and an error message will "
10501053"be displayed if the argument was not one of the acceptable values::"
10511054msgstr ""
1055+ "某些命令行参数应当从一组受限值中选择。 这可通过将一个容器对象作为 *choices* 关键字参数传给 "
1056+ ":meth:`~ArgumentParser.add_argument` 来处理。 "
1057+ "当执行命令行解析时,参数值将被检查,如果参数不是可接受的值之一就将显示错误消息::"
10521058
10531059#: ../../library/argparse.rst:1097
10541060msgid ""
10551061"Note that inclusion in the *choices* container is checked after any type_ "
10561062"conversions have been performed, so the type of the objects in the *choices*"
10571063" container should match the type_ specified::"
10581064msgstr ""
1065+ "请注意 *choices* 容器包含的内容会在执行任意 type_ 转换之后被检查,因此 *choices* 容器中对象的类型应当与指定的 type_ "
1066+ "相匹配::"
10591067
10601068#: ../../library/argparse.rst:1109
10611069msgid ""
10621070"Any container can be passed as the *choices* value, so :class:`list` "
10631071"objects, :class:`set` objects, and custom containers are all supported."
10641072msgstr ""
1073+ "任何容器都可作为 *choices* 值传入,因此 :class:`list` 对象,:class:`set` 对象以及自定义容器都是受支持的。"
10651074
10661075#: ../../library/argparse.rst:1114
10671076msgid "required"
@@ -1074,19 +1083,24 @@ msgid ""
10741083"command line. To make an option *required*, ``True`` can be specified for "
10751084"the ``required=`` keyword argument to :meth:`~ArgumentParser.add_argument`::"
10761085msgstr ""
1086+ "通常,:mod:`argparse` 模块会认为 ``-f`` 和 ``--bar`` 等旗标是指明 *可选的* 参数,它们总是可以在命令行中被忽略。 "
1087+ "要让一个选项成为 *必需的*,则可以将 ``True`` 作为 ``required=`` 关键字参数传给 "
1088+ ":meth:`~ArgumentParser.add_argument`::"
10771089
10781090#: ../../library/argparse.rst:1129
10791091msgid ""
10801092"As the example shows, if an option is marked as ``required``, "
10811093":meth:`~ArgumentParser.parse_args` will report an error if that option is "
10821094"not present at the command line."
10831095msgstr ""
1096+ "如这个例子所示,如果一个选项被标记为 "
1097+ "``required``,则当该选项未在命令行中出现时,:meth:`~ArgumentParser.parse_args` 将会报告一个错误。"
10841098
10851099#: ../../library/argparse.rst:1135
10861100msgid ""
10871101"Required options are generally considered bad form because users expect "
10881102"*options* to be *optional*, and thus they should be avoided when possible."
1089- msgstr ""
1103+ msgstr "必需的选项通常被认为是不适宜的,因为用户会预期 *options* 都是 *可选的*,因此在可能的情况下应当避免使用它们。 "
10901104
10911105#: ../../library/argparse.rst:1140
10921106msgid "help"
0 commit comments