看板 Python 關於我們 聯絡資訊
各位大大好, 請教以下程式碼為什麼不管呼叫test多少次 m陣列中都只有註冊到一次 該怎麼理解 謝謝~ m=[] def register(f): m.append(f) return f @register def test(): pass print m # m=[<function test at 0x7f24a6c76488>] test() print m # m=[<function test at 0x7f24a6c76488>] ----- Sent from JPTT on my iPhone -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 42.73.204.203 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1536302876.A.C14.html
djshen: 就只有@register那次 09/07 15:24
thefattiger: 呼叫函式不會讓decorator再包ㄧ次 09/07 17:33