本文整理汇总了Python中collections.MutableMapping.keys方法的典型用法代码示例。如果您正苦于以下问题:Python MutableMapping.keys方法的具体用法?Python MutableMapping.keys怎么用?Python MutableMapping.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collections.MutableMapping
的用法示例。
在下文中一共展示了MutableMapping.keys方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fromkeys
# 需要导入模块: from collections import MutableMapping [as 别名]
# 或者: from collections.MutableMapping import keys [as 别名]
def fromkeys(cls, iterable, value=None):
'''OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S.
If not specified, the value defaults to None.
'''
self = cls()
for key in iterable:
self[key] = value
return self
示例2: popitem
# 需要导入模块: from collections import MutableMapping [as 别名]
# 或者: from collections.MutableMapping import keys [as 别名]
def popitem(self):
'Remove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.'
try:
return self.maps[0].popitem()
except KeyError:
raise KeyError('No keys found in the first mapping.')
示例3: fromkeys
# 需要导入模块: from collections import MutableMapping [as 别名]
# 或者: from collections.MutableMapping import keys [as 别名]
def fromkeys(cls, iterable, value=None):
'''OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S
and values equal to v (which defaults to None).
'''
d = cls()
for key in iterable:
d[key] = value
return d