Python论坛  - 讨论区

标题:[python-chinese] 怎么理解a[1:3,:-1:2]?

2006年12月26日 星期二 14:21

linda.s samrobertsmith在gmail.com
星期二 十二月 26 14:21:07 HKT 2006

怎么理解a[1:3,:-1:2]?
>>> a
array([[ 0., 1., 2., 3., 4., 5.],
[ 6., 7., 8., 9., 10., 11.],
[ 12., 13., 14., 15., 16., 17.],
[ 18., 19., 20., 21., 22., 23.],
[ 24., 25., 26., 27., 28., 29.]])
>>> a[1:3,:-1:2]
array([[ 6., 8., 10.],
[ 12., 14., 16.]])

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

2006年12月26日 星期二 14:34

Zoom.Quiet zoom.quiet在gmail.com
星期二 十二月 26 14:34:11 HKT 2006

On 12/26/06, linda. s <samrobertsmith在gmail.com> wrote:
> 怎么理解a[1:3,:-1:2]?
很直观哪?!
将原数组的第2元素和 [:-1:2] 组成新数组,
不过 [:-1:2] 是什么操作?

> >>> a
> array([[ 0., 1., 2., 3., 4., 5.],
> [ 6., 7., 8., 9., 10., 11.],
> [ 12., 13., 14., 15., 16., 17.],
> [ 18., 19., 20., 21., 22., 23.],
> [ 24., 25., 26., 27., 28., 29.]])
> >>> a[1:3,:-1:2]
> array([[ 6., 8., 10.],
> [ 12., 14., 16.]])
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese


-- 
'''Time is unimportant, only life important!
blog@  http://blog.zoomquiet.org/pyblosxom/
wiki@    http://wiki.woodpecker.org.cn/moin/ZoomQuiet
douban@ http://www.douban.com/people/zoomq/
____________________________________
Please use OpenOffice.org to replace M$ office.
     http://zh.openoffice.org
Please use 7-zip to replace WinRAR/WinZip.
     http://7-zip.org/zh-cn/
You can get the truely Freedom from software.
'''

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

2006年12月26日 星期二 14:40

wkssy delux25在gmail.com
星期二 十二月 26 14:40:51 HKT 2006

1:3£¬È¡³öµÚ1¡¢2¸öÔªËØ¡ª¡ªÁ½¸öÁбí
:-1:2 ÿ¸öÁбíÀ´ÓÍ·µ½µ¹ÊýµÚÒ»¸öÖ®¼ä²½³¤Îª2È¡ÔªËØ

2006/12/26, Zoom. Quiet <zoom.quiet在gmail.com>:
>
> On 12/26/06, linda. s <samrobertsmith在gmail.com> wrote:
> > ÔõôÀí½âa[1:3,:-1:2]?
> ºÜÖ±¹ÛÄÄ£¿£¡
> ½«Ô­Êý×éµÄµÚ2ÔªËØºÍ [:-1:2] ×é³ÉÐÂÊý×飬
> ²»¹ý [:-1:2] ÊÇʲô²Ù×÷£¿
>
> > >>> a
> > array([[ 0., 1., 2., 3., 4., 5.],
> > [ 6., 7., 8., 9., 10., 11.],
> > [ 12., 13., 14., 15., 16., 17.],
> > [ 18., 19., 20., 21., 22., 23.],
> > [ 24., 25., 26., 27., 28., 29.]])
> > >>> a[1:3,:-1:2]
> > array([[ 6., 8., 10.],
> > [ 12., 14., 16.]])
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
> --
> '''Time is unimportant, only life important!
> blog@  http://blog.zoomquiet.org/pyblosxom/
> wiki@    http://wiki.woodpecker.org.cn/moin/ZoomQuiet
> douban@ http://www.douban.com/people/zoomq/
> ____________________________________
> Please use OpenOffice.org to replace M$ office.
>      http://zh.openoffice.org
> Please use 7-zip to replace WinRAR/WinZip.
>      http://7-zip.org/zh-cn/
> You can get the truely Freedom from software.
> '''
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20061226/76b96e68/attachment-0001.html 

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

2006年12月26日 星期二 14:53

Zoom.Quiet zoom.quiet在gmail.com
星期二 十二月 26 14:53:57 HKT 2006

On 12/26/06, wkssy <delux25在gmail.com> wrote:
> 1:3,取出第1、2个元素——两个列表
是也乎,1:3 是取 第2,3 元素

> :-1:2 每个列表里,从头到倒数第一个之间步长为2取元素
>
> 2006/12/26, Zoom. Quiet <zoom.quiet在gmail.com>:
> >
> > On 12/26/06, linda. s <samrobertsmith在gmail.com> wrote:
> > > 怎么理解a[1:3,:-1:2]?
> > 很直观哪?!
> > 将原数组的第2元素和 [:-1:2] 组成新数组,
> > 不过 [:-1:2] 是什么操作?
> >
> > > >>> a
> > > array([[ 0., 1., 2., 3., 4., 5.],
> > > [ 6., 7., 8., 9., 10., 11.],
> > > [ 12., 13., 14., 15., 16., 17.],
> > > [ 18., 19., 20., 21., 22., 23.],
> > > [ 24., 25., 26., 27., 28., 29.]])
> > > >>> a[1:3,:-1:2]
> > > array([[ 6., 8., 10.],
> > > [ 12., 14., 16.]])
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese在lists.python.cn
> > > Subscribe: send subscribe to
> python-chinese-request在lists.python.cn
> > > Unsubscribe: send unsubscribe to
> python-chinese-request在lists.python.cn
> > > Detail Info:
> http://python.cn/mailman/listinfo/python-chinese
> >
> >
> > --
> > '''Time is unimportant, only life important!
> > blog@  http://blog.zoomquiet.org/pyblosxom/
> > wiki@    http://wiki.woodpecker.org.cn/moin/ZoomQuiet
> > douban@ http://www.douban.com/people/zoomq/
> > ____________________________________
> > Please use OpenOffice.org to replace M$ office.
> >      http://zh.openoffice.org
> > Please use 7-zip to replace WinRAR/WinZip.
> >      http://7-zip.org/zh-cn/
> > You can get the truely Freedom from software.
> > '''
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to
> python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to
> python-chinese-request在lists.python.cn
> > Detail Info:
> http://python.cn/mailman/listinfo/python-chinese
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to
> python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to
> python-chinese-request在lists.python.cn
> Detail Info:
> http://python.cn/mailman/listinfo/python-chinese
>


-- 
'''Time is unimportant, only life important!
blog@  http://blog.zoomquiet.org/pyblosxom/
wiki@    http://wiki.woodpecker.org.cn/moin/ZoomQuiet
douban@ http://www.douban.com/people/zoomq/
____________________________________
Please use OpenOffice.org to replace M$ office.
     http://zh.openoffice.org
Please use 7-zip to replace WinRAR/WinZip.
     http://7-zip.org/zh-cn/
You can get the truely Freedom from software.
'''

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

2006年12月26日 星期二 15:01

wkssy delux25在gmail.com
星期二 十二月 26 15:01:34 HKT 2006

°³ÊýÊý´Ó0¿ªÊ¼£¬ºÇºÇ¡£¡£
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20061226/33fe88d9/attachment.htm 

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

2006年12月26日 星期二 15:03

xiaotian wu wu2xiaotian在gmail.com
星期二 十二月 26 15:03:56 HKT 2006

第一个元素下标为0,所以1:3取第1,2个元素。
按照人们习惯从元素从1开始的话,那就是第2,3个元素。

2006/12/26, Zoom. Quiet <zoom.quiet at gmail.com>:
>
> On 12/26/06, wkssy <delux25 at gmail.com> wrote:
> > 1:3,取出第1、2个元素――两个列表
> 是也乎,1:3 是取 第2,3 元素
>
> > :-1:2 每个列表里,从头到倒数第一个之间步长为2取元素
> >
> > 2006/12/26, Zoom. Quiet <zoom.quiet at gmail.com>:
> > >
> > > On 12/26/06, linda. s <samrobertsmith at gmail.com> wrote:
> > > > 怎么理解a[1:3,:-1:2]?
> > > 很直观哪?!
> > > 将原数组的第2元素和 [:-1:2] 组成新数组,
> > > 不过 [:-1:2] 是什么操作?
> > >
> > > > >>> a
> > > > array([[ 0., 1., 2., 3., 4., 5.],
> > > > [ 6., 7., 8., 9., 10., 11.],
> > > > [ 12., 13., 14., 15., 16., 17.],
> > > > [ 18., 19., 20., 21., 22., 23.],
> > > > [ 24., 25., 26., 27., 28., 29.]])
> > > > >>> a[1:3,:-1:2]
> > > > array([[ 6., 8., 10.],
> > > > [ 12., 14., 16.]])
> > > > _______________________________________________
> > > > 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
> > >
> > >
> > > --
> > > '''Time is unimportant, only life important!
> > > blog@  http://blog.zoomquiet.org/pyblosxom/
> > > wiki@    http://wiki.woodpecker.org.cn/moin/ZoomQuiet
> > > douban@ http://www.douban.com/people/zoomq/
> > > ____________________________________
> > > Please use OpenOffice.org to replace M$ office.
> > >      http://zh.openoffice.org
> > > Please use 7-zip to replace WinRAR/WinZip.
> > >      http://7-zip.org/zh-cn/
> > > You can get the truely Freedom from software.
> > > '''
> > > _______________________________________________
> > > 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
> >
>
>
> --
> '''Time is unimportant, only life important!
> blog@  http://blog.zoomquiet.org/pyblosxom/
> wiki@    http://wiki.woodpecker.org.cn/moin/ZoomQuiet
> douban@ http://www.douban.com/people/zoomq/
> ____________________________________
> Please use OpenOffice.org to replace M$ office.
>      http://zh.openoffice.org
> Please use 7-zip to replace WinRAR/WinZip.
>      http://7-zip.org/zh-cn/
> You can get the truely Freedom from software.
> '''
> _______________________________________________
> 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://python.cn/pipermail/python-chinese/attachments/20061226/3088a47f/attachment-0001.html 

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号