[python練習] 利用閉包返回一個計數器函數

利用閉包返回一個計數器函數,每次調用它返回遞增整數:python # -*- coding: utf-8 -*- # 你的代碼 # ... # 測試: counterA = createCounter() # 你的代碼 print(counterA(), counterA(), counterA(), counterA(), counterA()) # 1 2 3 4 5 counterB = c
相關文章
相關標籤/搜索