>>
>
"hello"
.upper(
)'hello'
>>
>
"hello"
.replace(
"e",
"**"
)'h**llo'
>>
> pool =
list()
>>
> pool
>>
> pool =
["fish"
,"turtle"
,"water"
]>>
> pool
['fish'
,'turtle'
,'water'
]>>
"加乙個"
)>>
"再乙個"
)>>
> pool
['fish'
,'turtle'
,'water'
,'加乙個'
,'再乙個'
]
>>
> pool =
>>
> pool
>>
> pool[
"1"]
'a'
rhymes =
n =input
("請輸入:"
)if n in rhymes:
rhyme = rhymes[n]
#此處要用中括號。字典用大括號,所以找人就低乙個級別
print
(rhyme)
else
:print
("沒找到"
)
lists =
rap =
["fafj"
,"jgajg"
,"asfk"
]rock =
["jzk"
,"ajnm"
,"jbgna"
]djs =
["nvzl"
,"gjgf"
,"fgklj"
]print
(lists)
1.建立乙個你最喜歡歌手的列表。
lists =
["歌手1"
,"歌手2"
]print
(lists)
2.建立乙個由元組構成的列表,每個元組包含居住過或旅遊過的城市的經緯度。
tuple1 =
("3516165"
,"416162665"
)print
(tuple1)
3.建立乙個包含你的不同屬性的字典:身高、最喜歡的顏色和最喜歡的作者等。
dic =
searching =
input
("輸入你想知道的事:"
)print
(dic[searching]
)
python第五章 Python學習(第五章)
記錄所有的名片字典 card list defshow menu 顯示資訊 print 50 print 歡迎使用 名片管理系統 v1.0 print print 1.新增名片 print 2.顯示全部 print 3.搜尋名片 print print 0.退出系統 print 50 defnew ...
python學習第五章
1.把某件事作為另一件事匯入 import somemodule或from somemodule import somefunction或者from somemodule import somefunction,anotherfunction,yetanotherfunction或者from som...
python學習筆記第五章
1.物件是屬性和方法的集合。同樣也有繼承機制。init 就是python的建構函式。變數私有化是在變數前加上 繼承機制 class cat def hello self print i m a cat class dog cat def eat self print i eat bone kitty...