Python dict copy()返回字典的副本。
dict.copy()
此方法返回字典的浅表副本。
以下示例显示了copy()方法的用法。
#!/usr/bin/python dict1={'Name': 'Learnfk', 'Age': 7}; dict2=dict1.copy() print "New Dictionary : %s" % str(dict2)
当无涯教程运行上面的程序时,它产生以下输出-
链接:https://www.learnfk.comhttps://www.learnfk.com/python/dictionary-copy.html
来源:LearnFk无涯教程网
New Dictionary : {'Age': 7, 'Name': 'Learnfk'}
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)