Python论坛  - 讨论区

标题:[python-chinese] List的赋值问题

2005年12月06日 星期二 08:28

超卓 chaoszhuo at gmail.com
Tue Dec 6 08:28:32 HKT 2005

据我的观察,Python的List的赋值实际是赋的指针。所以,需要将整个List赋值的话,我现在就是用for i in range
(len(x)):y.append(x[i]) 的办法。请问有没有更好的办法。

Chaos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20051206/27bfce4b/attachment.html

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2005年12月06日 星期二 09:05

Jason Liu telecomliu at gmail.com
Tue Dec 6 09:05:30 HKT 2005

在05-12-6,超卓 <chaoszhuo at gmail.com> 写道:
>
> 据我的观察,Python的List的赋值实际是赋的指针。所以,需要将整个List赋值的话,我现在就是用for i in range
> (len(x)):y.append(x[i]) 的办法。请问有没有更好的办法。
>

   y = x[:]

 Chaos
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20051206/870d0a58/attachment.htm

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2005年12月06日 星期二 14:50

超卓 chaoszhuo at gmail.com
Tue Dec 6 14:50:17 HKT 2005

hehe, 真的行呀!
这是个众所周知的秘密吧。哪里有说呀?我怎么没发现?

Chaos


在05-12-6,Jason Liu <telecomliu at gmail.com> 写道:
>
>
>
> 在05-12-6,超卓 <chaoszhuo at gmail.com> 写道:
> >
> > 据我的观察,Python的List的赋值实际是赋的指针。所以,需要将整个List赋值的话,我现在就是用for i in range
> > (len(x)):y.append(x[i]) 的办法。请问有没有更好的办法。
> >
>
>    y = x[:]
>
>  Chaos
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request at lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
> >
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20051206/ab188136/attachment.htm

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号