求问哪里错了
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 编辑 ]