Python论坛  - 讨论区

标题:答复: [python-chinese] 初学者问题

2004年08月10日 星期二 04:03

c[Box] cbox_wu at hotmail.com
Tue Aug 10 04:03:29 HKT 2004

看红色修改部分!

-----邮件原件-----
发件人: python-chinese-bounces at lists.python.cn
[mailto:python-chinese-bounces at lists.python.cn] 代表 詹建
发送时间: 2004年8月9日 21:04
收件人: python-chinese
主题: [python-chinese] 初学者问题


阅读 一切从游戏开始

抄书:
def calc(seq):
 maximum = 0
 max_item = []

 for i in seq:
  product = (i[0]*100 + i[1]*10 + i[2]) * (i[3]*10 + i[4])
  if product > maximum:
    maximum = product
    max_item = i
  elif product == maximum:
    max_item += ','+i
    return max_item, maximum
  return max_item, maximum

seq = [ [5,6,7,8,9], [5,6,7,9,8] ]
max_item,maximum = calc(seq)
print "Maximum at", max_item, ",product", maximum


命令行下:C:\pylearn\first-step>python 1.py
Traceback (most recent call last):
  File "1.py", line 15, in ?
    max_item,maximum = calc(seq)
TypeError: unpack non-sequence

这是怎么回事情?!

                          2004-08-09


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20040810/f38e15af/attachment.htm

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

2004年08月10日 星期二 09:33

Zoom.Quiet zoomquiet at infopro.cn
Tue Aug 10 09:33:24 HKT 2004

Hollo c[Box]:

  什么意思??
在下没有试最初的脚本,仅仅是享受了一下子阅读,然后提取优化的代码段使用的,


/******** [2004-08-10]09:31:41 ; c[Box] wrote:

c[Box]> 看红色修改部分!

c[Box]> -----邮件原件-----
c[Box]> 发件人: python-chinese-bounces at lists.python.cn
c[Box]> [mailto:python-chinese-bounces at lists.python.cn] 代表 詹建
c[Box]> 发送时间: 2004年8月9日 21:04
c[Box]> 收件人: python-chinese
c[Box]> 主题: [python-chinese] 初学者问题


c[Box]> 阅读 一切从游戏开始

c[Box]> 抄书:
c[Box]> def calc(seq):
c[Box]>  maximum = 0
c[Box]>  max_item = []

c[Box]>  for i in seq:
c[Box]>   product = (i[0]*100 + i[1]*10 + i[2]) * (i[3]*10 + i[4])
c[Box]>   if product > maximum:
c[Box]>     maximum = product
c[Box]>     max_item = i
c[Box]>   elif product == maximum:
c[Box]>     max_item += ','+i
c[Box]>     return max_item, maximum
c[Box]>   return max_item, maximum

c[Box]> seq = [ [5,6,7,8,9], [5,6,7,9,8] ]
c[Box]> max_item,maximum = calc(seq)
c[Box]> print "Maximum at", max_item, ",product", maximum


c[Box]> 命令行下:C:\pylearn\first-step>python 1.py
c[Box]> Traceback (most recent call last):
c[Box]>   File "1.py", line 15, in ?
c[Box]>     max_item,maximum = calc(seq)
c[Box]> TypeError: unpack non-sequence

c[Box]> 这是怎么回事情?!

c[Box]>                           2004-08-09




********************************************/

-- 
Free as in Freedom

 Zoom.Quiet                           

#=========================================#
]Time is unimportant, only life important![
#=========================================#

sender is the Bat!2.12.00



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

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

    你的回复:

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

    Zeuux © 2024

    京ICP备05028076号