我注意到一些带有/
参数的函数签名。可以在以下位置找到这方面的示例collections.Counter.__init__()
:
def __init__(self, iterable=None, /, **kwds):
'''Create a new, empty Counter object. And if given, count elements
from an input iterable. Or, initialize the count from another mapping
of elements to their counts.
>>> c = Counter() # a new, empty counter
>>> c = Counter('gallahad') # a new counter from an iterable
>>> c = Counter({'a': 4, 'b': 2}) # a new counter from a mapping
>>> c = Counter(a=4, b=2) # a new counter from keyword args
'''
super().__init__()
self.update(iterable, **kwds)
我无法找到它的用途,当我尝试在本地复制它时,我得到一个SyntaxError.
任何关于它是什么以及为什么使用它的信息将不胜感激。
慕田峪7331174
陪伴而非守候
相关分类