‘‘‘
切片复制时的id值与直接赋值的列表不一样
‘‘‘
list_pratisce = [5,6,8,9,19]
list_pratisce_backup = list_pratisce
list_pratisce_backup_qiepian = list_pratisce[:]
print(‘list_pratisce的值是:‘,id(list_pratisce),‘list_pratisce_backup的值是:‘,id(list_pratisce_backup),‘list_pratisce_backup_qiepian‘,id(list_pratisce_backup_qiepian))
打印结果:
list_pratisce的值是: 2028711862920 list_pratisce_backup的值是: 2028711862920 list_pratisce_backup_qiepian 2028711862984
原文地址:https://blog.51cto.com/9237101/2440127
时间: 2024-11-08 23:47:30