���� Python �̳� | ��9�� ���ݽṹ | |
---|---|---|
��һҳ | �ο� | ��һҳ |
���㴴��һ����������һ��������ʱ������������� �ο� �Ǹ��������DZ�ʾ�����������Ҳ����˵��������ָ���������д洢�Ǹ�������ڴ档�ⱻ�������Ƶ����������
һ��˵�����㲻��Ҫ���������ֻ���ڲο�����Щϸ��Ч����Ҫ��ע�⡣���ͨ������������Ӽ���˵����
#!/usr/bin/python
# Filename: reference.py
print
'Simple Assignment'
shoplist = [
'apple'
,
'mango'
,
'carrot'
,
'banana'
]
mylist = shoplist
# mylist is just another name pointing to the same object!
del
shoplist[
0
]
print
'shoplist is'
, shoplist
print
'mylist is'
, mylist
# notice that both shoplist and mylist both print the same list without
# the 'apple' confirming that they point to the same object
print
'Copy by making a full slice'
mylist = shoplist[:]
# make a copy by doing a full slice
del
mylist[
0
]
# remove first item
print
'shoplist is'
, shoplist
print
'mylist is'
, mylist
# notice that now the two lists are different
��Դ�ļ���code/reference.py��
$ python reference.py
Simple Assignment
shoplist is ['mango', 'carrot', 'banana']
mylist is ['mango', 'carrot', 'banana']
Copy by making a full slice
shoplist is ['mango', 'carrot', 'banana']
mylist is ['carrot', 'banana']
����������Ѿ��ڳ����ע�����ˡ�����Ҫ��ס��ֻ���������Ҫ����һ���б��������Ƶ����л����������ӵĶ����������������ļ� ���� ������ô�����ʹ����Ƭ��������ȡ�ÿ����������ֻ����Ҫʹ����һ�����������������ƶ� �ο� ͬһ��������ô����㲻С�ĵĻ������ܻ����������鷳��
��Perl����Ա��ע��
��ס�б��ĸ�ֵ������������������ʹ����Ƭ���������������еĿ�����
��һҳ | ��һ�� | ��һҳ |
---|---|---|
���� | ��ҳ | �����ַ��������� |