亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

這就是我的代碼。沒有輸出顯示,也沒有顯示錯


class Programer(object):
? ?def __init__(self,name,age):
? ? ? ?self.name=name
? ? ? ?if isinstance(age,int):
? ? ? ? ? ?self.age=age
? ? ? ?else:
? ? ? ? ? ?raise Exception('age must be int')
? ?def __eq__(self, other):
? ? ? ?if isinstance(other,Programer):
? ? ? ? ? ?if self.age==other.age:
? ? ? ? ? ? ? ?return ?True
? ? ? ? ? ?else:return False
? ? ? ?else:
? ? ? ? ? ?raise Exception('The type of object must be Programer')

? ?def __add__(self, other):
? ? ? ?if ?isinstance(other,Programer):
? ? ? ? ? ?return ?self.age+other.age
? ? ? ?else:
? ? ? ? ? ?raise Exception('The type of age must bu int')

if __name__=='main':
? ?p1=Programer('Albert',25)
? ?p2=Programer('bill',i0)
? ?print(p1==p2)
? ?print('.....')
? ?print(p1+p2)

正在回答

1 回答


不輸出原因如下:

if __name__=='main':? ? >>?if __name__=='__main__':

p2=Programer('bill',i0)? >>?p2=Programer('bill',10)

0 回復 有任何疑惑可以回復我~
#1

慕粉小陽01 提問者

非常感謝!
2018-02-28 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

這就是我的代碼。沒有輸出顯示,也沒有顯示錯

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號