Python论坛  - 讨论区

标题:[python-chinese] 关于tuple

2006年06月27日 星期二 08:20

linda.s samrobertsmith at gmail.com
Tue Jun 27 08:20:00 HKT 2006

以下程序为什么错?
>>> p
'\n3 1 5 5\n2 6 5 1\n10 1 44 10\n66 55 15 1 \n88 2  20 99\n'
>>> s=[ map(int,seg.split()) for seg in p.strip().split("\n")]
Traceback (most recent call last):
  File "", line 1, in ?
TypeError: 'tuple' object is not callable

Linda

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

2006年06月27日 星期二 08:56

Ni ZhengGang ni at twinisa.com
Tue Jun 27 08:56:44 HKT 2006

是不是你前面有一个tuple被命名为map?

linda.s 写道:
> 以下程序为什么错?
>>>> p
> '\n3 1 5 5\n2 6 5 1\n10 1 44 10\n66 55 15 1 \n88 2 20 99\n'
>>>> s=[ map(int,seg.split()) for seg in p.strip().split("\n")]
> Traceback (most recent call last):
> File "", line 1, in ?
> TypeError: 'tuple' object is not callable
>
> Linda
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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


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

2006年06月27日 星期二 09:06

linda.s samrobertsmith at gmail.com
Tue Jun 27 09:06:48 HKT 2006

好象没有啊,我试了一下:
>>> map


On 6/26/06, Ni ZhengGang <ni at twinisa.com> wrote:
> 是不是你前面有一个tuple被命名为map?
>
> linda.s 写道:
> > 以下程序为什么错?
> >>>> p
> > '\n3 1 5 5\n2 6 5 1\n10 1 44 10\n66 55 15 1 \n88 2 20 99\n'
> >>>> s=[ map(int,seg.split()) for seg in p.strip().split("\n")]
> > Traceback (most recent call last):
> > File "", line 1, in ?
> > TypeError: 'tuple' object is not callable
> >
> > Linda
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > 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
>

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

2006年06月27日 星期二 09:11

limodou limodou at gmail.com
Tue Jun 27 09:11:01 HKT 2006

On 6/27/06, linda. s <samrobertsmith at gmail.com> wrote:
> 好象没有啊,我试了一下:
> >>> map
> 
>
你换到python的dos命令行上再试试。就执行两句话:

p = '\n3 1 5 5\n2 6 5 1\n10 1 44 10\n66 55 15 1 \n88 2  20 99\n'
s=[ map(int,seg.split()) for seg in p.strip().split("\n")]

-- 
I like python!
My Blog: http://www.donews.net/limodou
My Django Site: http://www.djangocn.org
NewEdit Maillist: http://groups.google.com/group/NewEdit

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

2006年06月27日 星期二 09:22

linda.s samrobertsmith at gmail.com
Tue Jun 27 09:22:50 HKT 2006

On 6/26/06, limodou <limodou at gmail.com> wrote:
> On 6/27/06, linda. s <samrobertsmith at gmail.com> wrote:
> > 好象没有啊,我试了一下:
> > >>> map
> > 
> >
> 你换到python的dos命令行上再试试。就执行两句话:
>
> p = '\n3 1 5 5\n2 6 5 1\n10 1 44 10\n66 55 15 1 \n88 2  20 99\n'
> s=[ map(int,seg.split()) for seg in p.strip().split("\n")]
>
是正常的.
奇怪的是为什么在运行了一个相关的程序后(这两句在test.py里面),
python -i test.py
我重新给数值,为什么错呢?-i究竟有多大影响啊?
>>> p = '\n3 1 5 5\n2 6 5 1\n10 1 44 10\n66 55 15 1 \n88 2  20 99\n'
>>> p
'\n3 1 5 5\n2 6 5 1\n10 1 44 10\n66 55 15 1 \n88 2  20 99\n'
>>> s=[ map(int,seg.split()) for seg in p.strip().split("\n")]
Traceback (most recent call last):
  File "", line 1, in ?
TypeError: 'tuple' object is not callable

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

2006年06月27日 星期二 09:27

limodou limodou at gmail.com
Tue Jun 27 09:27:29 HKT 2006

On 6/27/06, linda. s <samrobertsmith at gmail.com> wrote:
> On 6/26/06, limodou <limodou at gmail.com> wrote:
> > On 6/27/06, linda. s <samrobertsmith at gmail.com> wrote:
> > > 好象没有啊,我试了一下:
> > > >>> map
> > > 
> > >
> > 你换到python的dos命令行上再试试。就执行两句话:
> >
> > p = '\n3 1 5 5\n2 6 5 1\n10 1 44 10\n66 55 15 1 \n88 2  20 99\n'
> > s=[ map(int,seg.split()) for seg in p.strip().split("\n")]
> >
> 是正常的.
> 奇怪的是为什么在运行了一个相关的程序后(这两句在test.py里面),
> python -i test.py
> 我重新给数值,为什么错呢?-i究竟有多大影响啊?
> >>> p = '\n3 1 5 5\n2 6 5 1\n10 1 44 10\n66 55 15 1 \n88 2  20 99\n'
> >>> p
> '\n3 1 5 5\n2 6 5 1\n10 1 44 10\n66 55 15 1 \n88 2  20 99\n'
> >>> s=[ map(int,seg.split()) for seg in p.strip().split("\n")]
> Traceback (most recent call last):
>   File "", line 1, in ?
> TypeError: 'tuple' object is not callable
>
我想是你的程序中有问题。你可以把程序就留下两行,执行。我想应该是没有问题的。一定是前面某个地方有问题。

-- 
I like python!
My Blog: http://www.donews.net/limodou
My Django Site: http://www.djangocn.org
NewEdit Maillist: http://groups.google.com/group/NewEdit

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号