返回顶部

收藏

Copy a dictionary

更多
L = [1,2,3]
D = {'a':1, 'b':2}

A = L[:]              # instead of: A = L (or list(L))
B = D.copy()          # instead of: B = D

A[1] = 'Ni'
B['c'] = 'spam'

print L, D

print A, B

标签:Python,Dictionary

收藏

0人收藏

支持

0

反对

0

发表评论