本文整理匯總了Python中collections.KeysView方法的典型用法代碼示例。如果您正苦於以下問題:Python collections.KeysView方法的具體用法?Python collections.KeysView怎麽用?Python collections.KeysView使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類collections
的用法示例。
在下文中一共展示了collections.KeysView方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_abc_registry
# 需要導入模塊: import collections [as 別名]
# 或者: from collections import KeysView [as 別名]
def test_abc_registry(self):
d = dict(a=1)
self.assertIsInstance(d.viewkeys(), collections.KeysView)
self.assertIsInstance(d.viewkeys(), collections.MappingView)
self.assertIsInstance(d.viewkeys(), collections.Set)
self.assertIsInstance(d.viewkeys(), collections.Sized)
self.assertIsInstance(d.viewkeys(), collections.Iterable)
self.assertIsInstance(d.viewkeys(), collections.Container)
self.assertIsInstance(d.viewvalues(), collections.ValuesView)
self.assertIsInstance(d.viewvalues(), collections.MappingView)
self.assertIsInstance(d.viewvalues(), collections.Sized)
self.assertIsInstance(d.viewitems(), collections.ItemsView)
self.assertIsInstance(d.viewitems(), collections.MappingView)
self.assertIsInstance(d.viewitems(), collections.Set)
self.assertIsInstance(d.viewitems(), collections.Sized)
self.assertIsInstance(d.viewitems(), collections.Iterable)
self.assertIsInstance(d.viewitems(), collections.Container)
示例2: keys
# 需要導入模塊: import collections [as 別名]
# 或者: from collections import KeysView [as 別名]
def keys(self):
return KeysView(self)
示例3: viewkeys
# 需要導入模塊: import collections [as 別名]
# 或者: from collections import KeysView [as 別名]
def viewkeys(self):
"Return set-like object with view of mapping keys."
return KeysView(self)
示例4: has_intrinsic_functions
# 需要導入模塊: import collections [as 別名]
# 或者: from collections import KeysView [as 別名]
def has_intrinsic_functions(parameter):
intrinsic_functions = ["Fn::Sub", "!Sub", "!GetAtt"]
result = False
if isinstance(parameter, (list, tuple, dict, KeysView)):
for item in parameter:
if item in intrinsic_functions:
result = True
break
return result
示例5: viewkeys
# 需要導入模塊: import collections [as 別名]
# 或者: from collections import KeysView [as 別名]
def viewkeys(self):
return collections.KeysView(self)
示例6: keys
# 需要導入模塊: import collections [as 別名]
# 或者: from collections import KeysView [as 別名]
def keys(self):
"""D.keys() => a set-like object providing a view on D's keys"""
return stdlib_collections.KeysView(self)