浅谈Python中copy()方法的使用,pythoncopy
浅谈Python中copy()方法的使用,pythoncopy
copy()方法返回字典的浅拷贝。
语法
以下是copy()方法的语法:
dict.copy()
参数
- NA
返回值
此方法返回字典的浅拷贝。
例子
下面的例子显示了copy()方法的使用。
#!/usr/bin/python dict1 = {'Name': 'Zara', 'Age': 7}; dict2 = dict1.copy() print "New Dictinary : %s" % str(dict2)
当我们运行上面的程序,它会产生以下结果:
New Dictinary : {'Age': 7, 'Name': 'Zara'}
相关内容
- 在Python中操作字典之fromkeys()方法的使用,pythonfromkeys
- 在Python中用get()方法获取字典键值的教程,pythonget
- 在Python中用has_key()方法查找键是否存在的教程,python
- Python中使用items()方法返回字典元素对的教程,pythonit
- 在Python中用keys()方法返回字典键的教程,pythonkeys
- 在Python中操作字典之setdefault()方法的使用,pythonsetdef
- python计算时间差的方法,python计算时间差
- 在Python中使用swapCase()方法转换大小写的教程,pythonsw
- python网络编程之数据传输UDP实例分析,pythonudp实例分析
- python中enumerate函数用法实例分析,pythonenumerate
评论关闭