Python -- 闂寘,,鏍囩锛?/p>姒傚


鏍囩锛?/p>

姒傚康

銆€銆€杩斿洖鍐呴儴鍑芥暟锛岃€屼笖鍐呴儴鍑芥暟鍜屽閮ㄥ嚱鏁扮殑灞€閮ㄥ彉閲忕粦瀹氬湪涓€璧?/p>


瀹炰緥1

def make_adder(addend):    def adder(augend):        return augend + addend    return adderp = make_adder(23)q = make_adder(44)print p(100)print q(100)

瀹炰緥2

def hellocounter (name):    count=0     def counter():        nonlocal count        count+=1        print("Hello, %s, %d access!" % (name, count))    return counterhello = hellocounter(鈥?/span>zoro鈥?/span>)hello()hello()hello()  

瀹炰緥3

def makebold(fn):    def wrapped():        return "<b>" + fn() + "</b>"    return wrappeddef makeitalic(fn):    def wrapped():        return "<i>" + fn() + "</i>"    return wrapped@makebold@makeitalicdef hello():    return "hello world"print(hello())

Python -- 闂寘

鏍囩锛?/p>

鍘熸枃鍦板潃锛歨ttp://www.cnblogs.com/roronoa-sqd/p/4899112.html

相关内容

    暂无相关文章

评论关闭