标题:求问哪里错了
取消只看楼主
hrg689689
Rank: 2
等 级:论坛游民
帖 子:7
专家分:27
注 册:2012-9-22
 问题点数:0 回复次数:0 
求问哪里错了
for yeath in range(1,100):
        xinhouzinum=0
        for men in menqun:
            baby=None
            if men.age >= 20 and men.ifpeiou():
                baby=men.peiou.shengbaby()
            else:
                for  women in womenqun:
                    if (women.age >= 20) and (men.peidui(women)):
                        baby=women.shengbaby()
                        break
            if baby:
                xinhouzinum+=1
                if baby.sex()=="公":
                    menqun.append(baby)
                else:
                    womenqun.append(baby)
            if men.age >= 60:
                menqun.remove(men)
                men.death()
            else:
                men.sumage()

Traceback (most recent call last):
  File "D:\Python32\MoKey\main.py", line 17, in <module>
    if (women.age >= 20) and (men.peidui(women)):
      
class MenMokey(Mokey):
    def __init__(self, id):
        Mokey.__init__(self, id)
        Tool.log("公猴子:" + self.id)

    def peidui(seif, peiou):
        Tool.log("向"+peiou.id+"配对")
        if(peiou.ifpeidui(self)):
            self.peiou=peiou
            Tool.log("高兴"+peiou.id+"接受了我")
            return True
        else:
            Tool.log("伤心"+peiou.id+"拒绝了我")
            return False
  File "D:\Python32\MoKey\MoKey.py", line 59, in peidui
    if(peiou.ifpeidui(self)):
NameError: global name 'self' is not defined




[ 本帖最后由 hrg689689 于 2012-9-23 13:47 编辑 ]
搜索更多相关主题的帖子: baby 
2012-09-23 13:45



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-381936-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.881269 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved