python 字典 update()
Python 字典(Dictionary) update() 函数把字典dict2的键/值对更新到dict里。dict2 – 添加到指定字典dict里的字典。#!/usr/bin/pythondict = {'Name': 'Zara', 'Age': 7}dict2 = {'Sex': 'female' }dict.update(dict2)print "Value : %s" ...
·
Python 字典(Dictionary) update() 函数把字典dict2的键/值对更新到dict里。
dict2 – 添加到指定字典dict里的字典。
#!/usr/bin/python
dict = {'Name': 'Zara', 'Age': 7}
dict2 = {'Sex': 'female' }
dict.update(dict2)
print "Value : %s" % dict
以上实例输出结果为:
Value : {'Age': 7, 'Name': 'Zara', 'Sex': 'female'}
a = {1:2,2:2}
b = {1:1,3:3}
b.update(a)
print(b)

更多推荐



所有评论(0)