你好!我想請教有關笨辦法學python習題48的問題

2021-04-14 05:53:11 字數 3698 閱讀 8904

1樓:

__init__方法在類的一個物件被建立時,馬上執行。這個方法可以用來對你的物件做一些你希望專的 初始化屬 。注意,這個名稱的開始和結尾都是雙下劃線。

建立def __init__(self,lyrics): 或者別的函式時候需要多加一個self變數:

如果不加self,lyrics= lyrics這樣的**意義就不明確了,它指的既可能例項的lyrics屬性,或者一個叫做lyrics的區域性變數。有了self.lyrics=lyrics你就知道這指的是例項的屬性self.

lyrics

2樓:**ile無峰

物件導向初始bai值du

賦值aa = song(["they rally around the family",

"with pockets full of shells"])aa唱的歌詞

zhi就是那個數列

lyrics 歌詞的dao意思吧

新手求教,笨方法學python的習題35問題

3樓:匿名使用者

#!usr/bin/python

# -*-coding:utf-8-*-

from sys import exit

def gold_room():

print("this room is full of gold.  how much do you take?")

next = input("> ")

if "0" in next or "1" in next:

how_much = int(next)

else:

dead("man, learn to type a number.")

if how_much < 50:

print("nice, you're not greedy, you win!")

exit(0)

else:

dead("you greedy bastard!")

def bear_room():

print ("there is a bear here.")

print ("the bear has a bunch of honey.")

print ("the fat bear is in front of another door.")

print ("how are you going to move the bear?")

bear_moved = false

while true:

next = input("> ")

if next == "take honey":

dead("the bear looks at you then slaps your face off.")

elif next == "taunt bear" and not bear_moved:

print("the bear has moved from the door. you can go through it now.")

bear_moved = true

elif next == "taunt bear" and bear_moved:

dead("the bear gets pissed off and chews your leg off.")

elif next == "open door" and bear_moved:

gold_room()

else:

print("i got no idea what that means.")

def cthulhu_room():

print ("here you see the great evil cthulhu.")

print ("he, it, whatever stares at you and you go insane.")

print ("do you flee for your life or eat your head?")

next = input("> ")

if "flee" in next:

start()

elif "head" in next:

dead("well that was tasty!")

else:

cthulhu_room()

def dead(why):

print(why,"good job")

exit(0)

def start():

print ("you are in a dark room.")

print ("there is a door to your right and left.")

print ("which one do you take?")

next = input("> ")

if next == "left":

bear_room()

elif next == "right":

cthulhu_room()

else:

dead("you stumble around the room until you starve.")

start()

執行結果如下:

you are in a dark room.

there is a door to your right and left.

which one do you take?

> left

there is a bear here.

the bear has a bunch of honey.

the fat bear is in front of another door.

how are you going to move the bear?

> taunt bear

the bear has moved from the door. you can go through it now.

> open door

this room is full of gold.  how much do you take?

> asf

man, learn to type a number. good job!

笨辦法學python,習題25import出錯

4樓:匿名使用者

兩種處理:

1、切換

來到源ex25.py的路徑下,再import。切換路徑命令:cd f:\pylearning

2、把ex25.py檔案複製到python安裝目錄的lib資料夾下面,在任意位置都可以import

5樓:匿名使用者

在敲入python之前,先復f:\ 回車制,然後再 cd f:\pylearning,再輸入python, 這樣就不會報錯了。

或者你在進入python提示後,import os, 然後輸入os.chdir('f:\\pylearning'), 再輸入import ex25就不會報錯了。

6樓:匿名使用者

當沒有切換到f:/pylearning時,不會從改目錄下查詢。需要切換到該目錄再import

7樓:匿名使用者

這個實際就是一復個制環境變數的問題,你把你寫

bai 的python檔案所

你好!我想請教一下你便祕是用的什麼辦法?謝謝

別聽他們瞎說,蜂蜜有的有效果有的沒有,你直接去醫院看,他們會給你建議的,而且也不用太著急,孕婦都存著便祕這個情況。泡蜂蜜水喝,又管用又營養!好像都沒什麼有用的方法 我長期便祕,很多年了,怎麼治?請教 我也是經常便祕的,試過很多辦法,把管用的推薦給你一些吧,可是試試看哦!1.香蕉 酸奶,早上起來空腹先...

你好,我妹妹撞車了,想請教索賠的事情

如果不是多大的事故私了是可以的,沒那麼多繁瑣的事。當事人可以找當地處理這次事故的交警大隊私了,責任劃分可以找交警大隊也可以找當地第三方事故權威鑑定。就是要塞點錢,如果社會關係比較硬,錢也免了。然後拿著鑑定書影印件,全車保險,身份證之類的到投保公司索賠就可以了。確定下劃分全責保險公司賠多少,對方給多少...

你好,我想諮詢紅斑狼瘡有關的問題

有紅斑狼瘡病的人,請家qq243922468 我也是狼瘡病人,2004年經常發低燒,但我堅持工作,2004年底我因大量心包積液入心血管科,當時下了病危通知。手術後,住院半個月我又回公司上班了。2004年底又病發了,又一次病危通知,最後確診為系統性紅斑狼瘡,醫院給我開了激素,環磷醯胺。我從生命線上回來...