Python中的for循环

Python中的for循环 - qiy校招算法选择题

list = []
for i in range(3):
    def test(x):
        print(x+i)
    list.append(test)
for num in list:
    num(2)

输出结果:

4
4
4

 

posted @ 2021-07-02 11:00  转角102  阅读(60)  评论(0编辑  收藏  举报