[問題] 新手又來發問了QAQ

看板Python作者 (walkman)時間10年前 (2014/04/01 21:31), 編輯推噓2(200)
留言2則, 2人參與, 最新討論串1/2 (看更多)
list_parent_answer.append(Find_Minimum(list_parent_v1)) list_parent_answer.append(Find_Minimum(list_parent_v2)) . . . list_parent_answer.append(Find_Minimum(list_parent_v10)) 假如我想要做這10行,有沒有辦法用迴圈做呢? list_parent_v1~v10 都是變數 我想要做成這樣 n=0 while(0<temp): list_parent_answer.append(Find_Minimum(list_parent_vn)) n += 1 temp -= 1 return list_parent_answer 請問有辦法做到這樣嗎QQ? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.124.201.37 ※ 文章網址: http://www.ptt.cc/bbs/Python/M.1396359082.A.683.html

04/01 21:40, , 1F
eval("list_parent_v" + str(n))
04/01 21:40, 1F

04/01 22:15, , 2F
locals() or globals() or obj.__getattribute__()
04/01 22:15, 2F
文章代碼(AID): #1JEh-gQ3 (Python)
文章代碼(AID): #1JEh-gQ3 (Python)