| 6 | 1/1 | 返回列表 |
| 查看: 1163 | 回復(fù): 5 | |||
yjcmwgk禁蟲 (文壇精英)
密度泛函·小卒
|
[求助]
以前從未接觸過類class,現(xiàn)在才開始學(xué)習(xí)class,出了個(gè)問題,誠心請(qǐng)教
|
|
各位高手好~我剛剛開始接觸面向?qū)ο蟮某绦蛟O(shè)計(jì),這里用的是python 2.7 我剛剛開始學(xué)習(xí)class,遇到問題肯定很幼稚,還請(qǐng)各位不吝賜教。 我規(guī)定了一個(gè)bird的class。這個(gè)bird類,有吃飯、喝水、起飛、降落、唱歌五種動(dòng)作。 我在__int__(self)中規(guī)定了三種初始狀態(tài),self.hungry = True,self.thirsty = True,self.insky = False 但是當(dāng)我運(yùn)行這個(gè)class的時(shí)候,出現(xiàn)問題了。系統(tǒng)告訴我bird instance has no attribute 'hungry' 我是真正的啥也不懂,剛剛開始學(xué)習(xí),翻書也沒看到問題的解決方法。誠心請(qǐng)教,十分感謝各位高手。 class bird的定義如下 使用這個(gè)class的時(shí)候出現(xiàn)了問題,如下 然后我嘗試把def __int__(self)改成了def __int__(self, hungry, thirsty, insky),問題仍舊存在。 我該如何解決?非常感謝各位高手! [ Last edited by yjcmwgk on 2012-6-21 at 14:37 ] |
榮譽(yù)版主 (文壇精英)
smallerpig

禁蟲 (文壇精英)
密度泛函·小卒
禁蟲 (文壇精英)
密度泛函·小卒
至尊木蟲 (著名寫手)
驃騎將軍

|
| 6 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 297求調(diào)劑 +3 | 田洪有 2026-03-30 | 3/150 |
|
|---|---|---|---|---|
|
[考研] 288資源與環(huán)境專碩求調(diào)劑,不限專業(yè),有學(xué)上就行 +8 | lllllos 2026-03-30 | 8/400 |
|
|
[考研] 求收留 +6 | 1943443204 2026-03-28 | 6/300 |
|
|
[考研] 286分調(diào)劑 +10 | Faune 2026-03-30 | 11/550 |
|
|
[考研] 一志愿華中師范化學(xué)332分求調(diào)劑 +3 | Lyy930824@ 2026-03-29 | 3/150 |
|
|
[考研] 332求調(diào)劑 +14 | 032500 2026-03-25 | 14/700 |
|
|
[考研] 085600,專業(yè)課化工原理,320分求調(diào)劑 +5 | 大饞小子 2026-03-29 | 5/250 |
|
|
[考研] 0703一志愿9,初試成績:338,四六級(jí)已過,有科研經(jīng)歷,求調(diào)劑! +7 | Zuhui0306 2026-03-25 | 7/350 |
|
|
[考研] 322求調(diào)劑 +10 | 宋明欣 2026-03-27 | 10/500 |
|
|
[考研] 287求調(diào)劑 +14 | land xuxu 2026-03-26 | 14/700 |
|
|
[考研] 環(huán)境科學(xué)與工程334分求調(diào)劑 +6 | 王一一依依 2026-03-30 | 8/400 |
|
|
[考研] 材料與化工272求調(diào)劑 +21 | 阿斯蒂芬2004 2026-03-28 | 21/1050 |
|
|
[考研] 一志愿北京工業(yè)大學(xué),324分求調(diào)劑 +6 | 零八# 2026-03-28 | 6/300 |
|
|
[碩博家園] 招收生物學(xué)/細(xì)胞生物學(xué)調(diào)劑 +4 | IceGuo 2026-03-26 | 5/250 |
|
|
[考研] 286求調(diào)劑 +12 | PolarBear11 2026-03-26 | 12/600 |
|
|
[考研] 調(diào)劑 +3 | 好好讀書。 2026-03-28 | 3/150 |
|
|
[考研]
|
18419759900 2026-03-25 | 8/400 |
|
|
[考研] 315調(diào)劑 +4 | 0860求調(diào)劑 2026-03-26 | 5/250 |
|
|
[考研] 314求調(diào)劑 +3 | 溪云珂 2026-03-26 | 3/150 |
|
|
[考研] 336材料求調(diào)劑 +7 | 陳瀅瑩 2026-03-26 | 9/450 |
|