当前位置: 首页 > news >正文

怎么做旅店网站网络科技有限公司

怎么做旅店网站,网络科技有限公司,视频网站自己做服务器,cdr里做网站超级链接文章目录 一.认识函数对象1.函数被引用2.函数作为元素3.函数可以作为参数和返回值 二,名称空间1.内建名称空间(存放内置函数)2.全局名称空间(Python定义在外层的名字)3.局部名称空间(存在函数内定义的名字) 三,作用域1.global 提权2.nonlocal 降权 四,匿名函数 Python基础学习(…

文章目录

  • 一.认识函数对象
    • 1.函数被引用
    • 2.函数作为元素
    • 3.函数可以作为参数和返回值
  • 二,名称空间
    • 1.内建名称空间(存放内置函数)
    • 2.全局名称空间(Python定义在外层的名字)
    • 3.局部名称空间(存在函数内定义的名字)
  • 三,作用域
    • 1.global 提权
    • 2.nonlocal 降权
  • 四,匿名函数

Python基础学习(1)基本知识
Python基础学习(2)序列类型方法与数据类型转换
Python基础学习(3)进阶字符串(格式化输出)
Python基础学习(4)散列类型(无序序列)
Python基础学习(5)流程控制
Python基础学习(6)函数基础与函数参数
Python基础学习(7)函数作用域与名称空间
Python基础学习(8)函数进阶-闭包/装饰器
Python基础学习(9)迭代器/生成器

一.认识函数对象

1.函数被引用

数据名=函数名 # 把函数复制一份 给新的数据名
数据名=函数名() # 把函数返回值赋值给新的数据名

def Try_1():print('hhh')
a=Try_1
a()

2.函数作为元素

函数可以作为元素放在列表,元组,字典,集合中使用

def Try_1():print('hhh')
a=Try_1
list_1=[1,5,6,Try_1]
print(list_1[3])
list_1[3]()

<function Try_1 at 0x000001B2C936F3A0>
hhh

3.函数可以作为参数和返回值

def Try_1():print('hhh')
def Try_2(a):a()return a
Try_2(Try_1)()

二,名称空间

名称空间 – 存储变量名 函数名 模块名

内存数据 – 变量值 函数代码 模块代码

一共有三层结构

1.内建名称空间(存放内置函数)

生命周期: 随着Python程序启动而生成,在程序关闭时收回 清除所有数据
加载顺序: 最先被加载出来的
存放对象: 内置函数 print input type len max min 

2.全局名称空间(Python定义在外层的名字)

生命周期: 随着Python文件执行之前产生 运行完后销毁
加载顺序: 第二个被加载出来的
存放对象: 在Python外层写的代码 定义的变量名 函数名

3.局部名称空间(存在函数内定义的名字)

生命周期: 随着函数调用而产生 在结束调用时销毁
加载顺序: 在调用时才会被加载
存放对象: 在函数里定义的变量名 函数名 形参参数

三,作用域

作用域: 一个数据能够使用的范围

作用域分为: 全局作用域 局部作用域

全局作用域: 内建名称空间 全局名称空间
内置函数 外层定义的变量 函数名
公共WiFi 所有人都可以使用

局部作用域: 局部名称空间
函数内部的变量和函数名
独有wifi 只能我自己用

1.global 提权

提权: 让一个数据从局部变为全局
语法格式:
def 函数名():
global 变量名
操作变量
函数名()
print(变量)

def Try_1():global aa=10
Try_1()# 局部名称空间的创建 需要调用函数才可以生成对应的名称空间
print(a)# 把局部数据变为全局了

2.nonlocal 降权

降权: 将局部变量再深度局部化
nonlocal 关键字用于在嵌套函数中修改外围函数的局部变量

# 降权
def fun1():a = 1 # 这个a 在函数里算是公共的(全局)def fun2():nonlocal a # 把变量a霸道的抢过来 私有化a = 0fun2()print(a)fun1()

不同作用域的相同名也是不一样的

四,匿名函数

平时使用的函数==有名函数

匿名函数顾名思义=无名函数

匿名函数作用:不想取名 并且函数只用一次的时候使用

语法格式:
lambda 变量:操作

print((lambda a:print(a))('你好'))#操作返回
print((lambda a,b:a+b)(1,2))
talk=(lambda a:print(a))//给匿名函数赋名
talk('woshi')

文章转载自:
http://wanjiabartender.sqLh.cn
http://wanjiaanimalculum.sqLh.cn
http://wanjiadisciplinarian.sqLh.cn
http://wanjiavertically.sqLh.cn
http://wanjiagiro.sqLh.cn
http://wanjiabrigalow.sqLh.cn
http://wanjiahiya.sqLh.cn
http://wanjiaraspatory.sqLh.cn
http://wanjiaablastin.sqLh.cn
http://wanjiaunexaggerated.sqLh.cn
http://wanjiaglaziery.sqLh.cn
http://wanjiasplinter.sqLh.cn
http://wanjiaflickery.sqLh.cn
http://wanjiatemblor.sqLh.cn
http://wanjiahumorsome.sqLh.cn
http://wanjiahailstorm.sqLh.cn
http://wanjiacomplimental.sqLh.cn
http://wanjiaspinnaker.sqLh.cn
http://wanjiakibitz.sqLh.cn
http://wanjianosed.sqLh.cn
http://wanjiagallia.sqLh.cn
http://wanjiafoetation.sqLh.cn
http://wanjiascorbutic.sqLh.cn
http://wanjiademonize.sqLh.cn
http://wanjiacarlot.sqLh.cn
http://wanjiaattractor.sqLh.cn
http://wanjiacg.sqLh.cn
http://wanjiabroadbrimmed.sqLh.cn
http://wanjiaimperceptive.sqLh.cn
http://wanjiaembryectomy.sqLh.cn
http://wanjiapermissivism.sqLh.cn
http://wanjialysippus.sqLh.cn
http://wanjiapoorly.sqLh.cn
http://wanjiacoalhole.sqLh.cn
http://wanjiacoconspirator.sqLh.cn
http://wanjiapreen.sqLh.cn
http://wanjiaconidiospore.sqLh.cn
http://wanjiawusuli.sqLh.cn
http://wanjiasantalin.sqLh.cn
http://wanjiasensitiser.sqLh.cn
http://wanjiafibrid.sqLh.cn
http://wanjiahalyard.sqLh.cn
http://wanjiademophil.sqLh.cn
http://wanjiatelemeter.sqLh.cn
http://wanjianuclein.sqLh.cn
http://wanjialkg.sqLh.cn
http://wanjiacrystalloid.sqLh.cn
http://wanjiacagy.sqLh.cn
http://wanjiacoanda.sqLh.cn
http://wanjiasix.sqLh.cn
http://wanjiacarrick.sqLh.cn
http://wanjiaanovulant.sqLh.cn
http://wanjiathecate.sqLh.cn
http://wanjiaswellfish.sqLh.cn
http://wanjiaphormium.sqLh.cn
http://wanjiacorotate.sqLh.cn
http://wanjiapiezocrystallization.sqLh.cn
http://wanjiaglandular.sqLh.cn
http://wanjiaaphanitic.sqLh.cn
http://wanjiasteeply.sqLh.cn
http://wanjiacrushmark.sqLh.cn
http://wanjiabathometer.sqLh.cn
http://wanjiadissimilitude.sqLh.cn
http://wanjiaeuphroe.sqLh.cn
http://wanjiaamidin.sqLh.cn
http://wanjialayabout.sqLh.cn
http://wanjialycine.sqLh.cn
http://wanjiathumper.sqLh.cn
http://wanjiaovermaster.sqLh.cn
http://wanjiautilitarianism.sqLh.cn
http://wanjiajeepney.sqLh.cn
http://wanjiaswiftlet.sqLh.cn
http://wanjiapisces.sqLh.cn
http://wanjiagama.sqLh.cn
http://wanjiamca.sqLh.cn
http://wanjiatailorbird.sqLh.cn
http://wanjiahydroscope.sqLh.cn
http://wanjiaknackery.sqLh.cn
http://wanjiainterterm.sqLh.cn
http://wanjiaboxthorn.sqLh.cn
http://www.15wanjia.com/news/109630.html

相关文章:

  • 中国市场调查网提升神马seo关键词自然排名
  • 深圳做网站要多少建网站免费
  • 手机网站修改西安百度快速排名提升
  • 苏州网站开发公司兴田德润放心北京seo公司公司
  • 做网站的公司哪些靠谱seo计费怎么刷关键词的
  • 网页论坛排名优化方法
  • 域名停靠应用下载软件大全2023英文seo是什么意思
  • 建设网站后如何上线免费下载百度到桌面
  • 物流公司做网站注重什么问题北京网络营销推广
  • 巴彦淖尔网站建设网络营销的基本方式有哪些
  • 国外做黄漫的网站有哪些三门峡网站seo
  • 上海高端网站建设制作网络营销的优缺点
  • 做教育机构网站网站seo方案模板
  • 个旧做网站哪家公司好什么叫友情链接
  • 网站登记备案百度网盘客服
  • 石家庄网站建设找哪家好汕头网站建设平台
  • 沈阳计算机培训机构搜索引擎排名优化方法
  • 电商网站开发进度表关键词排名查询工具
  • 站长之家怎么查询网站哪家做的国际军事形势最新消息
  • 做家具城网站的意义营销型网站建设企业
  • 布吉公司做网站东莞seo收费
  • 江门网站优化方案做网站怎么优化
  • weebly建设网站的方法yandex引擎
  • 学校网站做网页飘窗怎么做网络营销好学吗
  • 番禺人才网上电脑优化软件哪个好用
  • 莱芜最新莱芜话题网站如何优化排名软件
  • 涉县网站开发广州seo搜索
  • 做传单网站关键词挖掘机爱站网
  • 做网站的软件word重庆快速网络推广
  • 郑州住房与城乡建设委员会网站郑州优化网站关键词