[[DA series - Learn Python with Steem]](https://steemit.com/da-learnpythonwithsteem/@deanliu/da-series-learn-python-with-steem-00-coding) 是DA(@deanliu & @antonsteemit)關於「從Python程式語言實做Steem區塊鏈的入門」的系列,歡迎趕緊入列學習! 前情提要:[[DA series - Learn Python with Steem #04] 迴圈](https://steemit.com/da-learnpythonwithsteem/@deanliu/da-series-learn-python-with-steem-04) https://steemitimages.com/0x0/https://cdn.steemitimages.com/DQmbeN1PpqQC2JE5HbpXatb3apUfFhe68fPLctT95FiiRHq/cover.png 第#05堂課,今天我們來學習Python的~~**基本資料結構** ! ## Python的基本資料結構(Data Structure) 介紹完了一些基本運算之後,我們還差一點點基本觀念就可以進入比較有「寫程式」感覺的地方了。我們這章節要教的是**資料結構**,也就是一些有效率儲存自己資料的方式。例如上一章的最後面我們介紹到的List(傳統稱為Array,陣列),就是一個可以想像成**清單**的**資料結構**,讓我們把東西一樣一樣的放到裡面。 在我自己的經驗裡面,最基本也最實用的資料結構就是**List**以及**Dictionary**,基本上有了這兩種資料結構之後就可以很有效的解決大部分的問題了。所以我們今天就針對這兩種最基本的資料結構來做介紹。 ## List 首先我們來說說List。 List這種資料結構應該就是你想像得到最直觀的「清單」。首先我們可以宣告一個List,之後就可以慢慢的取用裡面所紀錄的變數(或是其他資料結構)。程式碼可以參考[tutorial_5_list.py](https://github.com/antoncoding/Python-x-Steem-tutorial/blob/master/tutorial_5_list.py)  這裡我們用一個List:`my_todo_list`來紀錄了三個字串,分別是今天待辦的三項事物。而 `count_todo` 就是`my_todo_list`的長度:`len(my_todo_list)`,也就是待辦事項數量。 接著透過一個For迴圈**依照順序**列印出裡面的內容。執行結果: ``` I have 3 tasks on my todo list today! They are: Homework Write on Steem Get a haircut ``` List有一些非常好用的method可以使用,其中最好用的就是 `.append()`跟 `.remove()`兩個。`append`就是加上去的意思,會把一個新的元素加到原本List的最後面。例如剛剛的`my_todo_list`,可以如下加入新的元素:  首先我們先看看現在my_todo_list裡面有什麼東西,接著就把兩樣新的代辦事項加入本張清單。最後我們可以再次印出目前清單裡的任務數量。執行結果如下: ``` ['Homework', 'Write on Steem', 'Get a haircut'] I have 5 tasks on my todo list now! ``` 原本只有三個東西的list,經過我們的兩次append之後就變成五樣待辦事項了。而相反的,當我們想要移除一樣東西時,我們可以使用`.remove()`:  執行結果: ``` ['Homework', 'Write on Steem', 'Get a haircut', 'Watch a movie', 'Sleep'] ['Get a haircut', 'Watch a movie', 'Sleep'] ``` 更多可以使用List的操作可以參考這份[官方文件](https://docs.python.org/3/tutorial/datastructures.html)。使用方法大多大同小異,就是在你的list後面加上`.method名稱(參數)`。 另外還有一個十分重要,如何access List裡面物件的方法就是使用它的index,也就是編號。在程式語言裡面,通常第一個元素的index都是0,然後慢慢累加。所以在上面這個長度只剩下三的`my_todo_list`裡面,我們可以分別使用`my_todo_list[0], my_todo_list[1], my_todo_list[2]`來取用這三個字串: 例如 ``` print(my_todo_list[1]) ``` 就會印出從頭數來第二個元素,也就是`Watch a movie`。 ## Dictionary 接著我們來介紹另外一個實用的資料結構,就是Dictionary。在剛剛介紹的List裡面,我們只能依照順序來存取裡面的檔案,或是只有在我們知道我們要的物件在「List的第幾個」時,才可以直接用index選用。 不過,在Dictionary裡面我們可以一次存進一個**Key - Value pair**,也就是一個`key`對應一個`值`,每次查詢的時候只要我們知道`key`就可以找到相對應的值。Dictionary在一個在生活中感覺比較容易想像的資料結構,就好像我們在查字典的時候,輸入`Apple`就會出現蘋果的相關介紹、輸入`Zoo`就會出現動物園的介紹,我們不需要知道Apple是字典裡的第幾個字、也不需要遍歷字典裡面所有的元素來找到他。 我們下面使用一個簡單的**電話簿**例子來操作。(範例程式位於[tutorial_5_dictionary.py](https://github.com/antoncoding/Python-x-Steem-tutorial/blob/master/tutorial_5_dictionary.py))。Dictionary的宣告是使用`{ }`符號,裡面則放滿了 `key : value`這樣的結構。要讀取資料時也跟List類似,是使用`[]`裡面放上你用來搜尋的key:  ``` 0906882331 876543219 Traceback (most recent call last): File "tutorial_5_dictionary.py", line 4, in <module> print(my_phone_book['Bob']) KeyError: 'Bob' ``` 這裡我們先在裡面存了兩筆紀錄,分別是我的與**Alice**的電話號碼。可以發現後面我們在取用前兩筆資料時都十分順利,直到第三比Bob的資料時,由於他並不在Dictionary裡面,所以程式就顯示了`KeyError`。 至於要怎麼增加新的key-pair到字典裡面呢?可以使用以下幾種方法:  一種是直接使用類似**Assign**值的方式,以後my_phone_book裡面的 Bob值就等於後面那串數字。另一種方法算是比較正規,是使用Dictionary裡面的`.update()` method來做更新。使用update的好處是可以一次增加好幾筆,其實也就是字面上「以後面傳入的字典幫忙這個字典更新」的意思,如: ``` my_phone_book.update({'Joey':'4738273643', 'Rachel':'8372381298', 'Monica':'8327192039'}) ``` 上面的例子就是一次加入了一大堆新的資料到原本的`my_phone_book`裡面。 如果有一天,你想要列出所有的人還有電話,也可以使用一個for迴圈來遍歷整個字典。但是寫法有一點小小的不同,要使用`dictionary.items()`來當作被遞迴的主體,才能同時看到key跟value。  執行結果: ``` Joey : 4738273643 myself : 0906882331 Monica : 8327192039 Rachel : 8372381298 Alice : 876543219 Bob : 09080706023 ``` 其中還有其他有用的method。例如可以列出所有的key的`.keys()`: ``` print(my_phone_book.keys()) ``` 結果: ``` ['Bob', 'Alice', 'Monica', 'Rachel', 'myself', 'Joey'] ``` 更多的method或細節依然可以參考比較完整的[官方文件](https://docs.python.org/3/tutorial/datastructures.html#dictionaries),我個人是覺得這些就滿夠用的啦! ## Homework time:練習題! 今天我們學了兩大資料結構,就來練習一下他們與迴圈的結合吧: 題目:使用一個python程式,製造出一個dictionary和一個list:dictionary的key是1~10的整數,value分別是他們的平方。而list則是紀錄了1~10的三次方 ([1, 8, 27,...,1000])。最後分別列印出這個list和dictionary。 參考解答: [tutorial_5_exercise.py](https://github.com/antoncoding/Python-x-Steem-tutorial/blob/master/tutorial_5_exercise.py) 我們下篇文章再見囉~下課!  <sub>*image - pixabay*</sub>
author | deanliu |
---|---|
permlink | da-series-learn-python-with-steem-05 |
category | da-learnpythonwithsteem |
json_metadata | {"tags":["da-learnpythonwithsteem","python","steem","cn-programming","cn"],"users":["deanliu","antonsteemit"],"image":["https://steemitimages.com/0x0/https://cdn.steemitimages.com/DQmbeN1PpqQC2JE5HbpXatb3apUfFhe68fPLctT95FiiRHq/cover.png","https://cdn.steemitimages.com/DQmXK5dWbeELdY9ua7erNE4WKjPQNwH4rnS9daRmMRE9pLX/image.png","https://cdn.steemitimages.com/DQmaRtbbdDFvASf9uyLEWPhHxJ6ft48zKjWsdRpmiBaocZF/image.png","https://cdn.steemitimages.com/DQmRqwNVZzJ179MXUrpuZkABwyM5brUBY71EGBG5YYjZqGE/image.png","https://cdn.steemitimages.com/DQmXbob9o8uWs5p8E5s9SjjXEK5RPcrkRHmgZhHvu1vzwWU/image.png","https://cdn.steemitimages.com/DQmRmgVNgWRFq131gnL3oAQaejDL9eozKRjLczTRYQ93Lmu/image.png","https://cdn.steemitimages.com/DQmSL7fFPNBmx22uajzGXcBb627et3eAq3xFmrL395HKM4r/image.png","https://cdn.steemitimages.com/DQmbTcEoAB7HRTxy11a1eDN8vREiGqxEMd7P3jJ3TGvGSTv/class-377117_1280.jpg"],"links":["https://steemit.com/da-learnpythonwithsteem/@deanliu/da-series-learn-python-with-steem-00-coding","https://steemit.com/da-learnpythonwithsteem/@deanliu/da-series-learn-python-with-steem-04","https://github.com/antoncoding/Python-x-Steem-tutorial/blob/master/tutorial_5_list.py","https://docs.python.org/3/tutorial/datastructures.html","https://github.com/antoncoding/Python-x-Steem-tutorial/blob/master/tutorial_5_dictionary.py","https://docs.python.org/3/tutorial/datastructures.html#dictionaries","https://github.com/antoncoding/Python-x-Steem-tutorial/blob/master/tutorial_5_exercise.py"],"app":"steemit/0.1","format":"markdown"} |
created | 2018-08-02 01:27:18 |
last_update | 2018-08-02 01:27:18 |
depth | 0 |
children | 16 |
last_payout | 2018-08-09 01:27:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 22.149 HBD |
curator_payout_value | 3.484 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 4,901 |
author_reputation | 3,090,651,334,998,114 |
root_title | "[DA series - Learn Python with Steem #05] 基本資料結構" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 66,821,415 |
net_rshares | 15,204,960,786,250 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
abit | 0 | 212,565,227,820 | 100% | ||
jademont | 0 | 30,176,487,235 | 10% | ||
coinbitgold | 0 | 48,986,544,304 | 80% | ||
fry | 0 | 814,911,304 | 100% | ||
wongshiying | 0 | 144,960,360 | 100% | ||
mark-waser | 0 | 28,928,596,270 | 25% | ||
blockchainbilly | 0 | 19,864,212,752 | 50% | ||
deanliu | 0 | 1,401,072,973,784 | 100% | ||
joythewanderer | 0 | 185,049,892,664 | 50% | ||
daynewright | 0 | 17,999,088,828 | 65% | ||
team-leibniz | 0 | 51,718,508,824 | 40% | ||
ace108 | 0 | 315,425,381,596 | 25% | ||
laoyao | 0 | 35,990,030,994 | 100% | ||
somebody | 0 | 1,334,070,096,629 | 100% | ||
midnightoil | 0 | 128,358,184,716 | 100% | ||
xiaohui | 0 | 724,950,856,348 | 100% | ||
oflyhigh | 0 | 2,520,199,024,369 | 100% | ||
xiaokongcom | 0 | 246,049,256 | 100% | ||
yulan | 0 | 15,106,488,386 | 100% | ||
rivalhw | 0 | 2,087,132,498,760 | 100% | ||
chinadaily | 0 | 210,256,960,109 | 100% | ||
helene | 0 | 841,975,258,563 | 100% | ||
ethansteem | 0 | 196,135,656,400 | 100% | ||
davidjkelley | 0 | 1,448,812,117 | 25% | ||
digital-wisdom | 0 | 15,892,559,201 | 25% | ||
ethical-ai | 0 | 5,235,994,277 | 25% | ||
jwaser | 0 | 6,098,636,243 | 25% | ||
damarth | 0 | 721,207,416 | 3% | ||
bwaser | 0 | 51,722,768 | 25% | ||
ellepdub | 0 | 457,150,139 | 25% | ||
rynow | 0 | 11,256,548,664 | 2% | ||
herpetologyguy | 0 | 52,869,318,896 | 25% | ||
handyman | 0 | 51,961,489 | 25% | ||
strong-ai | 0 | 4,448,194,620 | 25% | ||
luneknight | 0 | 386,023,308 | 100% | ||
redes | 0 | 966,543,767,340 | 19% | ||
lalala | 0 | 128,061,657,353 | 100% | ||
dapeng | 0 | 80,038,814,762 | 100% | ||
devilwsy | 0 | 2,271,567,269 | 100% | ||
janiceting | 0 | 2,269,207,805 | 100% | ||
lydiachan | 0 | 26,047,915,447 | 100% | ||
technoprogressiv | 0 | 3,372,795,564 | 25% | ||
little-peppers | 0 | 100,906,830,556 | 100% | ||
blackbunny | 0 | 109,679,660,619 | 100% | ||
lingfei | 0 | 66,838,925,781 | 100% | ||
yyyy | 0 | 463,266,610 | 100% | ||
alexis555 | 0 | 1,570,151,323,256 | 22% | ||
msg768 | 0 | 1,124,110,301 | 1% | ||
htliao | 0 | 250,638,274,198 | 38% | ||
wylo | 0 | 609,881,658 | 100% | ||
cryptoted | 0 | 112,853,322 | 100% | ||
jkkim | 0 | 76,723,970 | 10% | ||
nanosesame | 0 | 153,949,958,799 | 100% | ||
victorier | 0 | 80,207,069,745 | 100% | ||
exec | 0 | 86,440,965,193 | 100% | ||
eval | 0 | 816,120,329 | 100% | ||
aaronli | 0 | 18,699,028,733 | 50% | ||
susanli3769 | 0 | 171,728,622,215 | 100% | ||
that1consultant | 0 | 302,353,392 | 100% | ||
sanzo | 0 | 339,099,991 | 100% | ||
smartdeveloper | 0 | 351,618,363 | 76% | ||
sweetieprincess | 0 | 31,139,793,747 | 50% | ||
travelgirl | 0 | 53,186,250,442 | 41% | ||
zeekcryptominer | 0 | 310,473,235 | 100% | ||
catwomanteresa | 0 | 43,280,402,840 | 40% | ||
syh7758520 | 0 | 4,387,748,731 | 100% | ||
liangfengyouren | 0 | 1,375,531,254 | 50% | ||
idx | 0 | 11,357,438,713 | 100% | ||
openledgerio | 0 | 360,130,335 | 59% | ||
commbank | 0 | 347,922,527 | 57% | ||
ingdirect | 0 | 317,403,007 | 52% | ||
marcoharley1995 | 0 | 609,061,897 | 100% | ||
fr3eze | 0 | 72,488,766,410 | 50% | ||
icmarkets | 0 | 426,485,246 | 70% | ||
tvb | 0 | 37,168,128,208 | 50% | ||
skenan | 0 | 85,034,810,129 | 50% | ||
jessie901220 | 0 | 17,795,065,282 | 100% | ||
davidke20 | 0 | 8,673,551,974 | 50% | ||
dgorbunov | 0 | 532,458,333 | 100% | ||
ms8988 | 0 | 602,448,519 | 100% | ||
kettleandseagull | 0 | 9,843,604,465 | 100% | ||
minloulou | 0 | 58,145,372 | 6% | ||
bobdos | 0 | 73,955,099,781 | 100% | ||
lindalex | 0 | 269,172,745 | 50% | ||
winniex | 0 | 3,473,127,833 | 10% | ||
kimxinfo | 0 | 9,241,632,013 | 100% | ||
windowglass | 0 | 17,495,371,294 | 50% | ||
cnbuddy | 0 | 4,346,824,399 | 0.1% | ||
chann | 0 | 5,319,197,602 | 20% | ||
santiagocazorla | 0 | 611,934,887 | 100% | ||
lebin | 0 | 22,275,780,332 | 5% | ||
itchyfeetdonica | 0 | 13,214,247,447 | 100% | ||
coindzs | 0 | 182,721,346 | 100% | ||
auleo | 0 | 4,542,603,593 | 20% | ||
antonsteemit | 0 | 14,774,765,673 | 100% | ||
itsok | 0 | 7,382,651,379 | 100% | ||
cathvanlael | 0 | 122,840,630 | 100% | ||
r3aperz | 0 | 182,058,686 | 100% | ||
yumisee | 0 | 847,231,671 | 50% | ||
joeliew | 0 | 4,778,656,141 | 100% | ||
comingback | 0 | 256,093,817 | 12% | ||
vamos-amigo | 0 | 1,717,573,782 | 50% | ||
yjcps | 0 | 1,804,224,182 | 100% | ||
iipoh06 | 0 | 686,372,532 | 100% | ||
annabellenoelle | 0 | 103,897,826 | 100% | ||
topocho-rancio | 0 | 597,299,820 | 100% | ||
btccurrency1 | 0 | 54,738,143 | 100% | ||
ethanlee | 0 | 9,896,683,309 | 100% | ||
andrewnoel | 0 | 535,446,528 | 100% | ||
eondas | 0 | 510,385,838 | 100% | ||
liewsc | 0 | 590,648,563 | 50% | ||
xiaoliang | 0 | 93,453,681,833 | 20% | ||
darita84 | 0 | 524,780,772 | 100% | ||
honoru | 0 | 744,333,637 | 50% | ||
lzg | 0 | 249,593,009 | 50% | ||
hmayak | 0 | 317,867,720 | 100% | ||
springfall | 0 | 446,030,853 | 100% | ||
johnsonlai | 0 | 241,359,459 | 50% | ||
fishlucy | 0 | 24,528,293,270 | 50% | ||
pgr | 0 | 224,412,894 | 25% | ||
china-mobile | 0 | 544,772,282 | 100% | ||
cn-malaysia | 0 | 2,609,879,972 | 100% | ||
xiaoyuanwmm | 0 | 240,751,771 | 100% | ||
tydebbie | 0 | 1,045,805,662 | 50% | ||
ybeyond | 0 | 124,111,769 | 100% | ||
team-cn | 0 | 129,967,727,177 | 100% | ||
weitz | 0 | 257,134,952 | 50% | ||
hardmetal | 0 | 454,921,403 | 100% | ||
tecire | 0 | 606,678,485 | 100% | ||
jerseymikes | 0 | 606,270,868 | 100% | ||
coder-bts | 0 | 11,772,127,530 | 100% | ||
chick-fil-a | 0 | 608,182,913 | 100% | ||
redlobster | 0 | 610,799,833 | 100% | ||
fiveguys | 0 | 608,285,680 | 100% | ||
marcoy2j | 0 | 305,792,007 | 50% | ||
yuwen | 0 | 454,952,356 | 100% | ||
shuxue | 0 | 458,047,261 | 100% | ||
yingyu | 0 | 455,337,209 | 100% | ||
wuli | 0 | 458,434,733 | 100% | ||
huaxue | 0 | 458,434,726 | 100% | ||
shengwu | 0 | 458,434,714 | 100% | ||
vmkoko | 0 | 228,724,516 | 50% | ||
tiffany4ever | 0 | 117,593,218 | 50% | ||
dealmoon | 0 | 609,296,119 | 100% | ||
moonbbs | 0 | 609,186,117 | 100% | ||
bonefish | 0 | 609,102,486 | 100% | ||
chilis | 0 | 609,141,157 | 100% | ||
olive-garden | 0 | 609,102,486 | 100% | ||
zhuanzhibufu | 0 | 450,675,458 | 100% | ||
shine.wong | 0 | 84,357,551 | 50% | ||
shuxuan | 0 | 528,795,552 | 100% | ||
xiaowucw | 0 | 528,760,366 | 100% | ||
menshealthblog | 0 | 481,223,714 | 100% | ||
new-voices | 0 | 611,895,605 | 100% | ||
nozuonodie | 0 | 611,201,023 | 100% | ||
yamibuy | 0 | 611,201,023 | 100% | ||
zongli | 0 | 451,895,550 | 100% | ||
zhuxi | 0 | 449,051,530 | 100% | ||
blues-wclouds | 0 | 504,667,134 | 100% | ||
calebchang | 0 | 572,733,520 | 100% | ||
jidgabol | 0 | 128,129,932 | 100% | ||
bunnymandy | 0 | 174,063,108 | 50% | ||
teamcn-weekly | 0 | 610,526,137 | 100% | ||
teamcn-news | 0 | 610,526,137 | 100% | ||
roy-rogers | 0 | 610,526,137 | 100% | ||
wenxuecity | 0 | 610,526,137 | 100% | ||
huaren | 0 | 610,529,467 | 100% | ||
mitbbs | 0 | 610,529,467 | 100% | ||
teamcn | 0 | 610,526,137 | 100% | ||
cn-health | 0 | 609,781,973 | 100% | ||
cn-doctors | 0 | 609,781,973 | 100% | ||
wongmanman | 0 | 290,475,936 | 50% | ||
sachinmehta | 0 | 459,357,039 | 100% | ||
kissfirer | 0 | 608,017,172 | 100% | ||
lkvictor2005 | 0 | 7,498,314,185 | 100% |
我找到一個叫codecombat的學python網站,很好玩
author | aaronli |
---|---|
permlink | re-deanliu-da-series-learn-python-with-steem-05-20180802t051909694z |
category | da-learnpythonwithsteem |
json_metadata | {"tags":["da-learnpythonwithsteem"],"app":"steemit/0.1"} |
created | 2018-08-02 05:19:09 |
last_update | 2018-08-02 05:19:09 |
depth | 1 |
children | 3 |
last_payout | 2018-08-09 05:19:09 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.096 HBD |
curator_payout_value | 0.031 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 30 |
author_reputation | 350,939,913,840,685 |
root_title | "[DA series - Learn Python with Steem #05] 基本資料結構" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 66,838,895 |
net_rshares | 76,452,228,300 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
deanliu | 0 | 76,452,228,300 | 5% |
对呢 这个网站通过游戏学挺有意思 周围很多朋友用来教小孩子学
author | itchyfeetdonica |
---|---|
permlink | re-aaronli-re-deanliu-da-series-learn-python-with-steem-05-20180802t090455138z |
category | da-learnpythonwithsteem |
json_metadata | {"tags":["da-learnpythonwithsteem"],"app":"steemit/0.1"} |
created | 2018-08-02 09:04:57 |
last_update | 2018-08-02 09:04:57 |
depth | 2 |
children | 2 |
last_payout | 2018-08-09 09:04:57 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 30 |
author_reputation | 615,581,595,864,553 |
root_title | "[DA series - Learn Python with Steem #05] 基本資料結構" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 66,856,045 |
net_rshares | 0 |
我是小孩子
author | aaronli |
---|---|
permlink | re-itchyfeetdonica-re-aaronli-re-deanliu-da-series-learn-python-with-steem-05-20180802t121042831z |
category | da-learnpythonwithsteem |
json_metadata | {"tags":["da-learnpythonwithsteem"],"app":"steemit/0.1"} |
created | 2018-08-02 12:10:42 |
last_update | 2018-08-02 12:10:42 |
depth | 3 |
children | 1 |
last_payout | 2018-08-09 12:10:42 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 5 |
author_reputation | 350,939,913,840,685 |
root_title | "[DA series - Learn Python with Steem #05] 基本資料結構" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 66,870,775 |
net_rshares | 0 |
personally, for the print... I prefer <code> print(f'I have {count_todo} tasks on my todo list now!') </code>
author | ace108 |
---|---|
permlink | re-deanliu-da-series-learn-python-with-steem-05-20180802t051332869z |
category | da-learnpythonwithsteem |
json_metadata | {"tags":["da-learnpythonwithsteem"],"app":"steemit/0.1"} |
created | 2018-08-02 05:13:33 |
last_update | 2018-08-02 05:13:33 |
depth | 1 |
children | 0 |
last_payout | 2018-08-09 05:13:33 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.080 HBD |
curator_payout_value | 0.026 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 109 |
author_reputation | 1,225,393,856,970,278 |
root_title | "[DA series - Learn Python with Steem #05] 基本資料結構" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 66,838,502 |
net_rshares | 63,710,190,250 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
deanliu | 0 | 63,710,190,250 | 4% |
 Dictionary 不懂使用.format(key,value),所以多了{ },怎麼辦?
author | kona |
---|---|
permlink | re-deanliu-da-series-learn-python-with-steem-05-20180802t034140836z |
category | da-learnpythonwithsteem |
json_metadata | {"tags":["da-learnpythonwithsteem"],"image":["https://cdn.steemitimages.com/DQmXudTPf3vC8mtofdVbEdtP4pUAWXMgwT7rB7WmCAA8iHC/hw5.png"],"app":"steemit/0.1"} |
created | 2018-08-02 03:41:42 |
last_update | 2018-08-02 03:41:42 |
depth | 1 |
children | 5 |
last_payout | 2018-08-09 03:41:42 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.066 HBD |
curator_payout_value | 0.010 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 145 |
author_reputation | 39,758,138,507,499 |
root_title | "[DA series - Learn Python with Steem #05] 基本資料結構" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 66,831,307 |
net_rshares | 45,480,515,568 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
deanliu | 0 | 38,217,473,535 | 2.5% | ||
antonsteemit | 0 | 7,263,042,033 | 51% |
若是印出整個dictionary 就會有含 `{}` 你的`hw_list`本身就是一個字典,所以直接印出來就會出現 {}包在字典外圍。 `.format`的用法是將字串中的某一個東西取代為函數中的東西 例如`' 今天是 {} 月 {} 日'.format(5,19)` 就會分別把5, 19填入兩個框框之中: `今天是5月5日` 以你的例子可以寫成: `print(' {} : {} :{} '.format(m, hw_list[m], a))`
author | antonsteemit |
---|---|
permlink | re-kona-re-deanliu-da-series-learn-python-with-steem-05-20180805t124753150z |
category | da-learnpythonwithsteem |
json_metadata | {"community":"busy","app":"busy/2.5.4","format":"markdown","tags":["da-learnpythonwithsteem"],"users":[],"links":[],"image":[]} |
created | 2018-08-05 12:47:54 |
last_update | 2018-08-05 12:47:54 |
depth | 2 |
children | 1 |
last_payout | 2018-08-12 12:47:54 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 229 |
author_reputation | 7,534,465,964,895 |
root_title | "[DA series - Learn Python with Steem #05] 基本資料結構" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 67,187,276 |
net_rshares | 0 |
明白,謝謝解答,讓我再試試🙏🙏🙏
author | kona |
---|---|
permlink | re-antonsteemit-re-kona-re-deanliu-da-series-learn-python-with-steem-05-20180805t130246417z |
category | da-learnpythonwithsteem |
json_metadata | {"tags":["da-learnpythonwithsteem"],"app":"steemit/0.1"} |
created | 2018-08-05 13:02:48 |
last_update | 2018-08-05 13:02:48 |
depth | 3 |
children | 0 |
last_payout | 2018-08-12 13:02:48 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 16 |
author_reputation | 39,758,138,507,499 |
root_title | "[DA series - Learn Python with Steem #05] 基本資料結構" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 67,188,488 |
net_rshares | 0 |
@antonsteemit ... Posted using [Partiko Android](https://play.google.com/store/apps/details?id=io.partiko.android)
author | deanliu |
---|---|
permlink | deanliu-re-kona-re-deanliu-da-series-learn-python-with-steem-05-20180802t035929365z |
category | da-learnpythonwithsteem |
json_metadata | {"app":"partiko"} |
created | 2018-08-02 03:59:30 |
last_update | 2018-08-02 03:59:30 |
depth | 2 |
children | 2 |
last_payout | 2018-08-09 03:59:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 116 |
author_reputation | 3,090,651,334,998,114 |
root_title | "[DA series - Learn Python with Steem #05] 基本資料結構" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 66,832,836 |
net_rshares | 0 |
你這個呼叫外援的操作真的666666🤦♀️
author | nostalgic1212 |
---|---|
permlink | re-deanliu-deanliu-re-kona-re-deanliu-da-series-learn-python-with-steem-05-20180802t042253954z |
category | da-learnpythonwithsteem |
json_metadata | {"tags":["da-learnpythonwithsteem"],"app":"steemit/0.1"} |
created | 2018-08-02 04:22:54 |
last_update | 2018-08-02 04:22:54 |
depth | 3 |
children | 1 |
last_payout | 2018-08-09 04:22:54 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 22 |
author_reputation | 1,484,457,563,353,076 |
root_title | "[DA series - Learn Python with Steem #05] 基本資料結構" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 66,834,671 |
net_rshares | 0 |
我這週專門安排了一個下午準備抱著電腦去研究1-5,還請了外援😂~~總覺得以我的IQ可能會問題比學到的東西多~~
author | nostalgic1212 |
---|---|
permlink | re-deanliu-da-series-learn-python-with-steem-05-20180802t033448222z |
category | da-learnpythonwithsteem |
json_metadata | {"tags":["da-learnpythonwithsteem"],"app":"steemit/0.1"} |
created | 2018-08-02 03:34:48 |
last_update | 2018-08-02 03:34:48 |
depth | 1 |
children | 1 |
last_payout | 2018-08-09 03:34:48 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.018 HBD |
curator_payout_value | 0.002 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 55 |
author_reputation | 1,484,457,563,353,076 |
root_title | "[DA series - Learn Python with Steem #05] 基本資料結構" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 66,830,777 |
net_rshares | 12,739,157,845 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
deanliu | 0 | 12,739,157,845 | 0.5% |
得此英才,夫復何求? Posted using [Partiko Android](https://play.google.com/store/apps/details?id=io.partiko.android)
author | deanliu |
---|---|
permlink | deanliu-re-nostalgic1212-re-deanliu-da-series-learn-python-with-steem-05-20180802t035744688z |
category | da-learnpythonwithsteem |
json_metadata | {"app":"partiko"} |
created | 2018-08-02 03:57:45 |
last_update | 2018-08-02 03:57:45 |
depth | 2 |
children | 0 |
last_payout | 2018-08-09 03:57:45 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 108 |
author_reputation | 3,090,651,334,998,114 |
root_title | "[DA series - Learn Python with Steem #05] 基本資料結構" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 66,832,675 |
net_rshares | 0 |
 看完评论我觉得我的有点啰嗦,哈哈哈!@yjcps你可以当助教了~
author | shine.wong |
---|---|
permlink | re-deanliu-da-series-learn-python-with-steem-05-20180802t065954158z |
category | da-learnpythonwithsteem |
json_metadata | {"tags":["da-learnpythonwithsteem"],"community":"steempeak","app":"steempeak"} |
created | 2018-08-02 06:59:54 |
last_update | 2018-08-02 06:59:54 |
depth | 1 |
children | 0 |
last_payout | 2018-08-09 06:59:54 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.096 HBD |
curator_payout_value | 0.031 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 119 |
author_reputation | 1,329,335,530,903 |
root_title | "[DA series - Learn Python with Steem #05] 基本資料結構" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 66,846,540 |
net_rshares | 76,452,228,300 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
deanliu | 0 | 76,452,228,300 | 5% |
哈哈,来交[作业](https://busy.org/@yjcps/learnpythonwithsteem05-n09ajzsh91) 
author | yjcps |
---|---|
permlink | re-deanliu-da-series-learn-python-with-steem-05-20180802t052027311z |
category | da-learnpythonwithsteem |
json_metadata | {"community":"busy","app":"busy/2.5.4","format":"markdown","tags":["da-learnpythonwithsteem"],"users":["yjcps"],"links":["https://busy.org/@yjcps/learnpythonwithsteem05-n09ajzsh91"],"image":["https://ipfs.busy.org/ipfs/QmZfDC644VJorrPDaHzW9gkdKD8z5639v5i1u4E3nXop8s"]} |
created | 2018-08-02 05:20:27 |
last_update | 2018-08-02 05:20:27 |
depth | 1 |
children | 1 |
last_payout | 2018-08-09 05:20:27 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.258 HBD |
curator_payout_value | 0.084 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 155 |
author_reputation | 1,019,613,572,923 |
root_title | "[DA series - Learn Python with Steem #05] 基本資料結構" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 66,839,005 |
net_rshares | 204,020,234,515 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
deanliu | 0 | 203,872,608,800 | 15% | ||
shine.wong | 0 | 147,625,715 | 100% |
虽然不看你的课外总结我勉强能看懂,一部分靠猜的,但是我还是去补习下吧~
author | shine.wong |
---|---|
permlink | re-yjcps-re-deanliu-da-series-learn-python-with-steem-05-20180802t070125753z |
category | da-learnpythonwithsteem |
json_metadata | {"tags":["da-learnpythonwithsteem"],"community":"steempeak","app":"steempeak"} |
created | 2018-08-02 07:01:27 |
last_update | 2018-08-02 07:01:27 |
depth | 2 |
children | 0 |
last_payout | 2018-08-09 07:01:27 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 35 |
author_reputation | 1,329,335,530,903 |
root_title | "[DA series - Learn Python with Steem #05] 基本資料結構" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 66,846,670 |
net_rshares | 0 |