• <tfoot id='LcvCQ'></tfoot>
    <i id='LcvCQ'><tr id='LcvCQ'><dt id='LcvCQ'><q id='LcvCQ'><span id='LcvCQ'><b id='LcvCQ'><form id='LcvCQ'><ins id='LcvCQ'></ins><ul id='LcvCQ'></ul><sub id='LcvCQ'></sub></form><legend id='LcvCQ'></legend><bdo id='LcvCQ'><pre id='LcvCQ'><center id='LcvCQ'></center></pre></bdo></b><th id='LcvCQ'></th></span></q></dt></tr></i><div id='LcvCQ'><tfoot id='LcvCQ'></tfoot><dl id='LcvCQ'><fieldset id='LcvCQ'></fieldset></dl></div>

    <small id='LcvCQ'></small><noframes id='LcvCQ'>

      <bdo id='LcvCQ'></bdo><ul id='LcvCQ'></ul>

      <legend id='LcvCQ'><style id='LcvCQ'><dir id='LcvCQ'><q id='LcvCQ'></q></dir></style></legend>

      1. help() 输出中的斜线是什么意思?

        What does the slash mean in help() output?(help() 输出中的斜线是什么意思?)

        <small id='6f44z'></small><noframes id='6f44z'>

        <tfoot id='6f44z'></tfoot>

            <tbody id='6f44z'></tbody>
          <legend id='6f44z'><style id='6f44z'><dir id='6f44z'><q id='6f44z'></q></dir></style></legend>

                <bdo id='6f44z'></bdo><ul id='6f44z'></ul>
                  <i id='6f44z'><tr id='6f44z'><dt id='6f44z'><q id='6f44z'><span id='6f44z'><b id='6f44z'><form id='6f44z'><ins id='6f44z'></ins><ul id='6f44z'></ul><sub id='6f44z'></sub></form><legend id='6f44z'></legend><bdo id='6f44z'><pre id='6f44z'><center id='6f44z'></center></pre></bdo></b><th id='6f44z'></th></span></q></dt></tr></i><div id='6f44z'><tfoot id='6f44z'></tfoot><dl id='6f44z'><fieldset id='6f44z'></fieldset></dl></div>
                • 本文介绍了help() 输出中的斜线是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在 Python 3.4 的 help 输出中,/ 在右括号之前是什么意思?

                  What does the / mean in Python 3.4's help output for range before the closing parenthesis?

                  >>> help(range)
                  Help on class range in module builtins:
                  
                  class range(object)
                   |  range(stop) -> range object
                   |  range(start, stop[, step]) -> range object
                   |  
                   |  Return a virtual sequence of numbers from start to stop by step.
                   |  
                   |  Methods defined here:
                   |  
                   |  __contains__(self, key, /)
                   |      Return key in self.
                   |  
                   |  __eq__(self, value, /)
                   |      Return self==value.
                  
                                                          ...
                  

                  推荐答案

                  它表示 仅位置参数,您不能用作关键字参数的参数.在 Python 3.8 之前,此类参数只能在 C API 中指定.

                  It signifies the end of the positional only parameters, parameters you cannot use as keyword parameters. Before Python 3.8, such parameters could only be specified in the C API.

                  表示__contains__key参数只能按位置传入(range(5).__contains__(3)),不是作为关键字参数 (range(5).__contains__(key=3)),您可以在纯 Python 函数中使用位置参数.

                  It means the key argument to __contains__ can only be passed in by position (range(5).__contains__(3)), not as a keyword argument (range(5).__contains__(key=3)), something you can do with positional arguments in pure-python functions.

                  另请参阅 Argument Clinic 文档:

                  要在 Argument Clinic 中将所有参数标记为仅位置参数,请在最后一个参数之后的一行上单独添加一个 /,缩进与参数行相同.

                  To mark all parameters as positional-only in Argument Clinic, add a / on a line by itself after the last parameter, indented the same as the parameter lines.

                  以及(最近添加的)Python 常见问题解答:

                  函数参数列表中的斜杠表示它之前的参数是仅位置参数.仅位置参数是没有外部可用名称的参数.在调用接受仅位置参数的函数时,参数仅根据其位置映射到参数.

                  A slash in the argument list of a function denotes that the parameters prior to it are positional-only. Positional-only parameters are the ones without an externally-usable name. Upon calling a function that accepts positional-only parameters, arguments are mapped to parameters based solely on their position.

                  语法现在是 Python 语言规范的一部分,as版本 3.8,请参阅 PEP 570 - Python Positional-Only 参数.在 PEP 570 之前,该语法已被保留以备将来可能包含在 Python 中,请参阅 PEP 457 -仅位置参数的语法.

                  The syntax is now part of the Python language specification, as of version 3.8, see PEP 570 – Python Positional-Only Parameters. Before PEP 570, the syntax was already reserved for possible future inclusion in Python, see PEP 457 - Syntax For Positional-Only Parameters.

                  仅位置参数可以使 API 更简洁明了,使纯 Python 实现的其他纯 C 模块更加一致且更易于维护,并且由于仅位置参数需要很少的处理,它们会导致更快的 Python 代码.

                  Positional-only parameters can lead to cleaner and clearer APIs, make pure-Python implementations of otherwise C-only modules more consistent and easier to maintain, and because positional-only parameters require very little processing, they lead to faster Python code.

                  这篇关于help() 输出中的斜线是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Split a Pandas column of lists into multiple columns(将 Pandas 的列表列拆分为多列)
                  How does the @property decorator work in Python?(@property 装饰器在 Python 中是如何工作的?)
                  What is the difference between old style and new style classes in Python?(Python中的旧样式类和新样式类有什么区别?)
                  How to break out of multiple loops?(如何打破多个循环?)
                  How to put the legend out of the plot(如何将传说从情节中剔除)
                  Why is the output of my function printing out quot;Nonequot;?(为什么我的函数输出打印出“无?)
                • <legend id='ToqUq'><style id='ToqUq'><dir id='ToqUq'><q id='ToqUq'></q></dir></style></legend>
                • <i id='ToqUq'><tr id='ToqUq'><dt id='ToqUq'><q id='ToqUq'><span id='ToqUq'><b id='ToqUq'><form id='ToqUq'><ins id='ToqUq'></ins><ul id='ToqUq'></ul><sub id='ToqUq'></sub></form><legend id='ToqUq'></legend><bdo id='ToqUq'><pre id='ToqUq'><center id='ToqUq'></center></pre></bdo></b><th id='ToqUq'></th></span></q></dt></tr></i><div id='ToqUq'><tfoot id='ToqUq'></tfoot><dl id='ToqUq'><fieldset id='ToqUq'></fieldset></dl></div>

                    • <bdo id='ToqUq'></bdo><ul id='ToqUq'></ul>

                        <small id='ToqUq'></small><noframes id='ToqUq'>

                        1. <tfoot id='ToqUq'></tfoot>
                            <tbody id='ToqUq'></tbody>