python核心编程-封包

#! /usr/bin/env python
# -*- conding: UTF -*-

def counter(start_at = 0):
    count = [start_at]
    def incr():
        count[0] += 1
        return count[0]
    return incr


count = counter(100)
print count()
count2 = counter(5)
print count2()
print count()

输出:

D:\Python27\test>func22.py
101
6
102

D:\Python27\test>

你可能感兴趣的:([,python基础,])