本文整理匯總了Python中misc.Misc.merge_dicts方法的典型用法代碼示例。如果您正苦於以下問題:Python Misc.merge_dicts方法的具體用法?Python Misc.merge_dicts怎麽用?Python Misc.merge_dicts使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類misc.Misc
的用法示例。
在下文中一共展示了Misc.merge_dicts方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_merge_dicts_overlapping_key_same_value
# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import merge_dicts [as 別名]
def test_merge_dicts_overlapping_key_same_value(self):
dict_a = {'a': 1, 'b': 2}
dict_b = {'b': 2, 'd': 4}
should_be = {'a': 1, 'b': 2, 'd': 4}
result = Misc.merge_dicts(dict1=dict_a, dict2=dict_b)
self.assertDictEqual(should_be, result)
示例2: test_merge_dicts_overlapping_key_different_value
# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import merge_dicts [as 別名]
def test_merge_dicts_overlapping_key_different_value(self):
dict_a = {'a': 1, 'b': 2}
dict_b = {'b': 3, 'd': 4}
with self.assertRaises(Exception) as cm:
Misc.merge_dicts(dict1=dict_a, dict2=dict_b)
self.assertTrue('Conflict at b' in cm.exception)
示例3: test_merge_dicts
# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import merge_dicts [as 別名]
def test_merge_dicts(self):
dict_a = {'a': 1, 'b': 2}
dict_b = {'c': 3, 'd': 4}
should_be = {'a': 1, 'b': 2, 'c': 3, 'd': 4}
result = Misc.merge_dicts(dict1=dict_a, dict2=dict_b)
self.assertDictEqual(should_be, result)