[問題] 關於list的append問題
hi 這幾天寫程式,有幾個關於list apeend的問題要跟大家請教。
1. 我寫了一個for迴圈,可以print 很多list,例如以下程式碼
for shop_link in shop_table:
. ....
print shop_link
output:
['leerentveld', 'mohell', 'vinoph', ]
['mdefelice', 'iamthemomo', 'tvenchus', ]
我該如和變成以下的name_list呢?這種把兩種list內的值合起來
name_ist = ['leerentveld', 'mohell', 'vinoph', 'mdefelice', 'iamthemomo', 'tvenchus',]
name_ist = ['leerentveld', 'mohell', 'vinoph', 'mdefelice', 'iamthemomo', 'tvenchus',]
我第一種嘗試為
name_list= []
for shop_link in shop_table:
. ....
print shop_link
name_list.append(shop_link)
output:
[ ['leerentveld', 'mohell', 'vinoph', ],
['mdefelice', 'iamthemomo', 'tvenchus', ] ]
我打算使用append的方式一個個加入,可是輸出卻不是我想要的,變成[[ ],[ ]]了請問我該如何修改
--
Sent from my Windows
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.172.97.181
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.172.97.181
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1460194271.A.728.html
※ 編輯: busystudent (223.140.224.116), 04/09/2016 17:37:29
推
04/09 17:41, , 1F
04/09 17:41, 1F
→
04/09 17:43, , 2F
04/09 17:43, 2F
→
04/09 17:54, , 3F
04/09 17:54, 3F
→
04/09 19:19, , 4F
04/09 19:19, 4F
推
04/09 20:42, , 5F
04/09 20:42, 5F
→
04/09 21:10, , 6F
04/09 21:10, 6F
→
04/09 21:11, , 7F
04/09 21:11, 7F
推
04/09 21:17, , 8F
04/09 21:17, 8F
→
04/09 21:17, , 9F
04/09 21:17, 9F
→
04/09 21:18, , 10F
04/09 21:18, 10F
→
04/09 21:33, , 11F
04/09 21:33, 11F
→
04/10 08:31, , 12F
04/10 08:31, 12F
→
04/10 08:32, , 13F
04/10 08:32, 13F
Python 近期熱門文章
PTT數位生活區 即時熱門文章