闭包:嵌套函数,且内部函数调用外部函数的变量

def outer():

  a=1

  def inner():

    print(a)

outer()

#####常见的闭包形式:将函数名作为返回值存储在内存里。

def outer():

  a=1

  def inner():

    print(a)

  return inner

inn=outer()

小应用:

from urllib.request import urlopen

def get_url():

  url="http://www.xiaohua100.cn/index.html"

   def get():

    ret=urlopen(url).read()

    print(ret)

  return get

get_url()