Python3 列表
描述
copy() 函數(shù)用于復(fù)制列表,類(lèi)似于 a[:]。
語(yǔ)法
copy()方法語(yǔ)法:
list.copy()
參數(shù)
- 無(wú)。
返回值
返回復(fù)制后的新列表。
實(shí)例
以下實(shí)例展示了 copy()函數(shù)的使用方法:
#!/usr/bin/python3
list1 = ['Google', 'W3CSchool', 'Taobao', 'Baidu']
list2 = list1.copy()
print ("list2 列表: ", list2)
以上實(shí)例輸出結(jié)果如下:
list2 列表: ['Google', 'W3CSchool', 'Taobao', 'Baidu']
更多建議: