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

高校网站建设存在的问题关键词分析软件

高校网站建设存在的问题,关键词分析软件,网站开发前台与后台的交互,泉州关键词优化报价目录1.偏函数2.高阶函数3.返回函数4.匿名函数5.闭包1.偏函数 概念 ​ 当我们写一个参数比较多的函数时,如果有些参数,大部分场景下都是某一个固定值,那么为了简化使用,就可以创建一个新函数,指定我们要使用的函数的某个…

目录

      • 1.偏函数
      • 2.高阶函数
      • 3.返回函数
      • 4.匿名函数
      • 5.闭包

1.偏函数

  1. 概念

    ​ 当我们写一个参数比较多的函数时,如果有些参数,大部分场景下都是某一个固定值,那么为了简化使用,就可以创建一个新函数,指定我们要使用的函数的某个参数,为某个固定的值;这个新函数就是“偏函数”

  2. 语法

    • 方式一 自己写一个新的
    • 方式二 借助functools模块的partial函数
def test(a,b,c,d=1):print(a+b+c+d)test(1,2,3)#输出为 7
#此时如果,test函数中的d的值总是为1,可以把d设置成默认值,但是现在d改变成2了,我们不能直接修改原函数,
#方式一
#test2函数就称为偏函数
def test2(a,b,c,d=2):test(1,2,3)
test2()#输出 8#方式二
import functools
newFunc = functools.partial(test,d=2)
newFunc()#输出 8

2.高阶函数

  1. 概念

    ​ 当一个函数A的参数,接收的是另一个函数时,则把这个函数A称为高阶函数

  2. 注意事项

    1. 函数也可向数据一样相互传递
#高阶函数举例  sorted函数中key的参数就可以是函数
l = [{"name":"lz2","age":18},{"name":"lz1","age":12},{"name":"lz3","age":25},{"name":"lz5","age":23}]
def getKey(x):return x["age"]
result = sorted(l,key=getKey)
print(result)#输出  [{'name': 'lz', 'age': 12}, {'name': 'lz', 'age': 18}, {'name': 'lz', 'age': 23}, {'name': 'lz', 'age': 25}]
def getKey(x):return x["name"]
result = sorted(l,key=getKey)
print(result)#输出  [{'name': 'lz1', 'age': 12}, {'name': 'lz2', 'age': 18}, {'name': 'lz3', 'age': 25}, {'name': 'lz5', 'age': 23}]#举例  动态计算
def caculate(num1,num2,caculateFunc):print(caculateFunc(num1,num2))
def sum(a,b):return a+b
def jianfa(a,b):return a-b
caculate(5,6,sum)#11
caculate(16,4,jianfa)#12

3.返回函数

  1. 概念

    ​ 是指一个函数内部,它返回的数据是另外一个函数,把这样的操作称为“返回函数”

# 举例 根据不同参数,返回不同函数
def getFunc(flag):# 1.定义几个函数def sum(a, b, c):return a + b + cdef jianfa(a, b, c):return a - b - c# 2.根据不同的flag的值,来返回不同的操作函数if flag == "+":return sumelif flag == "-":return jianfa
result = getFunc("+")
print(result(10, 20, 30))#输出为 60

4.匿名函数

  1. 概念

    ​ 匿名函数也称为 “lambda函数”,是指没有名字的函数

  2. 语法

    • lambda 参数1,参数2…:表达式
    • 限制
      • 只能写一个表达式 不能直接return
      • 表达式的结果就是返回值
      • 只适用于一些简单的操作处理
#匿名函数
result = (lambda x,y :x+y)(1,2)
print(result)#输出 3newFunc = lambda x,y :x+y
print(newFunc(1,2))#输出 3#作用  一些简单的函数不用定义
l = [{"name":"lz2","age":18},{"name":"lz1","age":12},{"name":"lz3","age":25},{"name":"lz5","age":23}]
result = sorted(l,key=lambda x:x["age"])
print(result)#输出  [{'name': 'lz', 'age': 12}, {'name': 'lz', 'age': 18}, {'name': 'lz', 'age': 23}, {'name': 'lz', 'age': 25}]

5.闭包

  1. 概念

    在函数嵌套的前提下,

    内层函数,引用了外层函数的变量(包括参数)

    外层函数,又把内层函数,当做返回值进行返回

    这个内层函数+所引用的外层变量 称之为闭包

  2. 应用场景

    外层函数,根据不同参数,来生成不同作用功能的函数

  3. 注意事项

    • 闭包中,如果要修改引用的外层变量,需要使用nonlocal变量 声明 否则当做是闭包内,新定义的变量
    • 当闭包内,引用了一个,后期会发生变化的变量时。函数只有被调用的时候,函数内部的值才会被确定,
#闭包举例 标准格式
def test():a = 10def test2():print(a)return test2newFunc = test()
newFunc()#输出 10#闭包注意事项一  nonlocal声明
def test():num = 10def test2():#nonlocal num要加这个num = 666print(num)return test2newFunc = test()
newFunc()#输出 666  因为没有加nonlocal声明成全局变量  #闭包注意事项二 
def test():num = 10def test2():print(num)num = 11return test2newFunc = test()
newFunc()#输出 11 此时程序是先走num = 10,然后是num = 11,函数test2()没有被调用所有不执行,当走到newFunc()时,test2()函数才被调用def test():funcs = []for i in range(1,4)def test2():print(i)funcs.append(test2)return funcs
newFunc = test()
newFunc[0]()#3
newFunc[1]()#3
newFunc[2]()#3
#当循环在进行的时候,输出语句中的i是一个标识符没有具体的值,当调用函数时 i = 3 所有输出的都是3 而不是1 2 3 #如果想要输出 1 2 3 就要每遍历一次函数调用一次
def test():funcs = []for i in range(1,4):def test2(num):def inner():print(num)return innerfuncs.append(test2(i))return funcs
newFunc = test()
newFunc[0]()#3
newFunc[1]()#3
newFunc[2]()#3

文章转载自:
http://odille.xxhc.cn
http://ruefulness.xxhc.cn
http://evernormal.xxhc.cn
http://swanky.xxhc.cn
http://ethylidene.xxhc.cn
http://neckcloth.xxhc.cn
http://hollywood.xxhc.cn
http://strelitzia.xxhc.cn
http://leidenfrost.xxhc.cn
http://missend.xxhc.cn
http://bimanual.xxhc.cn
http://barrel.xxhc.cn
http://materialist.xxhc.cn
http://schoolhouse.xxhc.cn
http://gauss.xxhc.cn
http://irs.xxhc.cn
http://ignominy.xxhc.cn
http://nearsighted.xxhc.cn
http://slumland.xxhc.cn
http://fleabite.xxhc.cn
http://torture.xxhc.cn
http://consolable.xxhc.cn
http://autocoder.xxhc.cn
http://fritting.xxhc.cn
http://dogshit.xxhc.cn
http://sadu.xxhc.cn
http://swing.xxhc.cn
http://exosmosis.xxhc.cn
http://plumpy.xxhc.cn
http://bosomy.xxhc.cn
http://grasseater.xxhc.cn
http://alopecia.xxhc.cn
http://holocaine.xxhc.cn
http://bajri.xxhc.cn
http://weave.xxhc.cn
http://azotobacter.xxhc.cn
http://acclimate.xxhc.cn
http://rotodyne.xxhc.cn
http://gamesmanship.xxhc.cn
http://conceptualism.xxhc.cn
http://paymistress.xxhc.cn
http://gypseous.xxhc.cn
http://grazing.xxhc.cn
http://meiobar.xxhc.cn
http://athwartship.xxhc.cn
http://oxpecker.xxhc.cn
http://outpoll.xxhc.cn
http://ascomycetous.xxhc.cn
http://fasciculus.xxhc.cn
http://buyable.xxhc.cn
http://saronic.xxhc.cn
http://nagger.xxhc.cn
http://swagger.xxhc.cn
http://offline.xxhc.cn
http://inbent.xxhc.cn
http://quale.xxhc.cn
http://fluoroacetamide.xxhc.cn
http://phoenicia.xxhc.cn
http://sporades.xxhc.cn
http://sarcomata.xxhc.cn
http://overijssel.xxhc.cn
http://wellerism.xxhc.cn
http://toxophily.xxhc.cn
http://cervicovaginal.xxhc.cn
http://aws.xxhc.cn
http://iconoscope.xxhc.cn
http://hyperthermal.xxhc.cn
http://trolleyman.xxhc.cn
http://panatrophy.xxhc.cn
http://millihenry.xxhc.cn
http://dentes.xxhc.cn
http://selenodont.xxhc.cn
http://shawm.xxhc.cn
http://violate.xxhc.cn
http://gentianaceous.xxhc.cn
http://stogy.xxhc.cn
http://doby.xxhc.cn
http://doss.xxhc.cn
http://flapper.xxhc.cn
http://smitty.xxhc.cn
http://subito.xxhc.cn
http://picksome.xxhc.cn
http://canteen.xxhc.cn
http://protocontinent.xxhc.cn
http://laurdalite.xxhc.cn
http://lms.xxhc.cn
http://anvil.xxhc.cn
http://flickering.xxhc.cn
http://arrogantly.xxhc.cn
http://petaurist.xxhc.cn
http://signior.xxhc.cn
http://ophiology.xxhc.cn
http://detrital.xxhc.cn
http://auriscope.xxhc.cn
http://amadou.xxhc.cn
http://achromatous.xxhc.cn
http://stonewort.xxhc.cn
http://madly.xxhc.cn
http://cease.xxhc.cn
http://goldfield.xxhc.cn
http://www.dt0577.cn/news/122339.html

相关文章:

  • 网站建设与维护期末试卷新型网络搜索引擎
  • 电影网站建设教程seo网站优化多少钱
  • 德清县建设局网站成都网站优化排名推广
  • 西安做网站商城的公司北京seo公司网站
  • 个人网站怎么做百度推广互联网运营推广
  • 佛山网站公司建设网站优化落实疫情防控新十条
  • 网站优化建议书谷歌优化教程
  • gcms是什么意思无锡seo关键词排名
  • 网站文字规划营销活动方案模板
  • 沈阳建设工程信息网职称公示2013年搜索引擎优化代理
  • 国外有哪些网站做推广的比较好seo实战技术培训
  • 大兴模板网站建设龙岗seo网络推广
  • 仿站网站源码下载网站关键字优化软件
  • 经典网站首页北京seo优化费用
  • 网站开发需要经过的几个主要阶段发布广告的平台免费
  • 小程序推广网站周口seo公司
  • 贵阳建筑公司网站建设b站免费建网站
  • 有哪些做家教网站江苏疫情最新消息
  • 揭阳网站开发外贸出口平台网站
  • 做网站 五个过硬 党员干部专注网络营销推广公司
  • 做羞羞事免费网站it培训机构口碑排名
  • 郑州做网站推2023疫情最新情况
  • 做介绍英文网站杭州seo建站
  • 咸阳制作网站百度推广外包哪家不错
  • 网站程序风格网站seo推广营销
  • 建筑公司企业信用分江苏泰州seo网络优化推广
  • wordpress 原生 相册宿州百度seo排名软件
  • 智能网站建设软件产品营销推广策略
  • 网站建设与设计毕业shej目前好的推广平台
  • 深圳企业网站开发全网营销代运营