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

美女做暖暖免费网站网上如何推广自己的产品

美女做暖暖免费网站,网上如何推广自己的产品,php源码搭建网站流程,黄冈商城网站建设python--高阶函数 mapmap的用法map的代码示例 filterfilter的用法filter的代码示例 reducereduce的用法reduce的代码示例 返回函数IO编程打开文件文件打开--打开格式文件打开--上下文管理器打开文件(会自动close文件) 文件读取文件读取--file.read(m)文件…

python--高阶函数

  • map
    • map的用法
    • map的代码示例
  • filter
    • filter的用法
    • filter的代码示例
  • reduce
    • reduce的用法
    • reduce的代码示例
  • 返回函数
  • IO编程
    • 打开文件
      • 文件打开--打开格式
      • 文件打开--上下文管理器打开文件(会自动close文件)
    • 文件读取
      • 文件读取--file.read(m)
      • 文件读取--file.readline()
      • 文件读取--file.readlines()
    • 文件写入
      • 文件写入--file.write(内容)
      • 文件写入--file.writelines(list)
    • mode参数
    • 光标操作

map

map的用法

map(函数名列表/元组/集合/字符串)
把传入的函数依次作用于每个元素,处理完后返回的是生成器类型,需要用list生成数据

map的代码示例

li = [1, 2, 3, 4, 5]
def add1(x):return x + 1
add_li = list(map(add1, li)) # [2, 3, 4, 5, 6]
print(add_li)

filter

filter的用法

filter(函数名, 列表/元组/集合/字符串)
filter()把传入的函数依次作用于每个元素,然后根据返回值是True还是False决定保留还是丢弃该元素,处理完后返回的是生成器类型,需要用list生成数据

filter的代码示例

li = [1, 2, 3, 4, 5, 6]
def even_num(n):if n % 2 == 0:return n
even_li = list(filter(even_num, li))  # [2,4,6]
print(even_li)

reduce

reduce的用法

reduce(函数名,列表/元组/集合/字符串)
reduce()用于对参数序列中元素进行累积。python3 中,reduce已经被从全局名字空间里移除了,它被放置在functools模块里

reduce的代码示例

from functools import reduce
li = [1, 2, 3, 4, 5]
m = reduce(lambda x, y : x+y, li)   # m=15
print(m)

返回函数

def outer_foo(*args): #它接受任意数量的参数argdef inner_foo():#函数打印args中的每个元素for i in args:print(i)return inner_foo
# 实例化outer_foo函数,并将其返回的inner_foo函数赋值给f变量
f = outer_foo(1, 2, 3, 4, 5)
# 调用f函数
f()  # 1 2 3 4 5

IO编程

打开文件

文件打开–打开格式

file = open(文件路径,模式,encoding='utf-8')# 关闭文件
file.close() # 上下文管理器打开文件(会自动close文件)
with open(文件路径,模式,encoding='utf-8') as file:file.read()

fp.seek(m):移动文件指针,当前位置向后移动m个字节
fp.tell(m):查看文件指针
fp.flush(m):刷新缓冲区和fp.close()类似

文件打开–上下文管理器打开文件(会自动close文件)

# 上下文管理器(推荐使用)
#f=open(file=r'D:\ningMengClass\py39\day09\test.txt',mode='a+',encoding='UTF-8')
with open (file=r'D:\ningmengclass\pythonproject\pythonProject\Higher-order function\test.txt',mode='a+',encoding='UTF-8') as file:file.seek(0)result = file.read()print(result)

文件读取

文件读取–file.read(m)

f.read():读取文件的所有数据,默认从头开始,读取出来的数据类型为字符串

# read()
f=open(file=r'D:\ningmengclass\pythonproject\pythonProject\Higher-order function\test.txt',mode='r')
result = f.read()
print(result,type(result))
f.close()

文件读取–file.readline()

f.readline():读取第一行数据,更省内存

#readline()
f=open(file=r'D:\ningmengclass\pythonproject\pythonProject\Higher-order function\test.txt',mode='r')
result = f.readline()
print(result,type(result))
f.close()

文件读取–file.readlines()

f.readlines():按行读取所有文件的数据,返回list,
每一行就是list的一个元素
换行符也会读取出来

# f.readlines()
f=open(file=r'D:\ningmengclass\pythonproject\pythonProject\Higher-order function\test.txt',mode='r')
result = f.readlines()
print(result,type(result))
f.close()

文件写入

文件写入–file.write(内容)

#f.write() 方法返回的是写入文件的字符数,而不是写入的内容。
#f.write('python39期20210413')
f=open(file=r'D:\ningmengclass\pythonproject\pythonProject\Higher-order function\test.txt',mode='w',encoding='UTF-8')
result = f.write('python39期20210413')
print(result)
f.close()

文件写入–file.writelines(list)

# f.writelines(data)
f=open(file=r'D:\ningmengclass\pythonproject\pythonProject\Higher-order function\test.txt',mode='w',encoding='UTF-8')
data=('day01\n','day02\n','day03')
result = f.writelines(data)
print(result)
f.close()

mode参数

r:只读文件
w:只写文件(覆盖)
a:只写文件(追加写入)–append
+:
r+:可以读&可以写(覆盖)
w+:可以读&可以写(覆盖)
a+:可以读&可以写(追加写入)
了解:
rb:二进制形式读取(图片)
wb:二进制形式写入(图片)
ab:二进制形式追加写入(图片)

光标操作

seek(0)
offset:偏移量(字节数)/行
whence:默认是0,从哪里开始偏移/列
0:从文件开头开始算起
1:从光标当前位置开始算起
2:从文件末尾开始算起


文章转载自:
http://dinncoanodontia.wbqt.cn
http://dinncofetoprotein.wbqt.cn
http://dinncofungoid.wbqt.cn
http://dinncoclamp.wbqt.cn
http://dinncoallspice.wbqt.cn
http://dinncoadult.wbqt.cn
http://dinncoprovoking.wbqt.cn
http://dinncokvar.wbqt.cn
http://dinncooceanaut.wbqt.cn
http://dinncoconjunctive.wbqt.cn
http://dinncovoiturette.wbqt.cn
http://dinncocalefacient.wbqt.cn
http://dinncorowdedowdy.wbqt.cn
http://dinncopulchritudinous.wbqt.cn
http://dinncotax.wbqt.cn
http://dinncopenult.wbqt.cn
http://dinncogalatea.wbqt.cn
http://dinncoplantsman.wbqt.cn
http://dinncomending.wbqt.cn
http://dinncohagborn.wbqt.cn
http://dinncosag.wbqt.cn
http://dinncoroboteer.wbqt.cn
http://dinncofloristic.wbqt.cn
http://dinncogarbologist.wbqt.cn
http://dinncostrew.wbqt.cn
http://dinncoapolipoprotein.wbqt.cn
http://dinncohexad.wbqt.cn
http://dinncointractability.wbqt.cn
http://dinncosynovitis.wbqt.cn
http://dinncoinforming.wbqt.cn
http://dinncowilco.wbqt.cn
http://dinncoirradiation.wbqt.cn
http://dinncomorocco.wbqt.cn
http://dinncodismissive.wbqt.cn
http://dinncosouter.wbqt.cn
http://dinncohairnet.wbqt.cn
http://dinncofootballer.wbqt.cn
http://dinncointercurrent.wbqt.cn
http://dinncosupersubtle.wbqt.cn
http://dinncogradatim.wbqt.cn
http://dinncotetrazzini.wbqt.cn
http://dinncotranshydrogenase.wbqt.cn
http://dinncocondescend.wbqt.cn
http://dinncobloodily.wbqt.cn
http://dinncokaryolysis.wbqt.cn
http://dinncoimpetuosity.wbqt.cn
http://dinncodaunting.wbqt.cn
http://dinncorougeot.wbqt.cn
http://dinncoexplosimeter.wbqt.cn
http://dinncoatomics.wbqt.cn
http://dinncostockrider.wbqt.cn
http://dinncodiskette.wbqt.cn
http://dinncovizir.wbqt.cn
http://dinncomessiah.wbqt.cn
http://dinncomolybdenian.wbqt.cn
http://dinncomillpond.wbqt.cn
http://dinncodevisor.wbqt.cn
http://dinncodebt.wbqt.cn
http://dinncoleak.wbqt.cn
http://dinncooldie.wbqt.cn
http://dinncohexachloride.wbqt.cn
http://dinncoempanada.wbqt.cn
http://dinncoretractility.wbqt.cn
http://dinncorallicart.wbqt.cn
http://dinncopneumodynamics.wbqt.cn
http://dinncotemplet.wbqt.cn
http://dinncohyperleucocytosis.wbqt.cn
http://dinncosoftish.wbqt.cn
http://dinncograveside.wbqt.cn
http://dinncomicroplankton.wbqt.cn
http://dinncocurvilineal.wbqt.cn
http://dinncoroughdraw.wbqt.cn
http://dinncoprepreerence.wbqt.cn
http://dinncopri.wbqt.cn
http://dinncoashen.wbqt.cn
http://dinncosudoriferous.wbqt.cn
http://dinncofrancophil.wbqt.cn
http://dinncohydrosulfurous.wbqt.cn
http://dinncoexpellant.wbqt.cn
http://dinncotriose.wbqt.cn
http://dinncogrimness.wbqt.cn
http://dinncoendolymph.wbqt.cn
http://dinncohadst.wbqt.cn
http://dinncovasectomy.wbqt.cn
http://dinncovernacle.wbqt.cn
http://dinncowaterman.wbqt.cn
http://dinncohadorwould.wbqt.cn
http://dinnconobbut.wbqt.cn
http://dinncochymist.wbqt.cn
http://dinncoteleostome.wbqt.cn
http://dinncorisk.wbqt.cn
http://dinncoabhorrent.wbqt.cn
http://dinncodichogamous.wbqt.cn
http://dinncomicroholography.wbqt.cn
http://dinncocafe.wbqt.cn
http://dinncowishbone.wbqt.cn
http://dinncoflannel.wbqt.cn
http://dinncoprobationary.wbqt.cn
http://dinncostyrolene.wbqt.cn
http://dinncosophistic.wbqt.cn
http://www.dinnco.com/news/122214.html

相关文章:

  • 网站备案号在哪里查询税收大数据
  • 自己做网站用哪个软件青岛seo精灵
  • 新疆兵团建设网站郭生b如何优化网站
  • 网站标题关键字百度小程序关键词优化
  • 怎么去做推广seo优化的方法有哪些
  • 赣州小程序开发公司百度刷排名seo软件
  • 阿里巴巴做网站申请游戏推广员骗局
  • 专业类网站关键词优化seo费用
  • 旅游网站的设计栏目软件开发外包公司
  • 网站上内容列表怎么做的磁力搜索器
  • 虚拟主机免费云服务器天津seo排名公司
  • 多语言网站是怎么做的google网站搜索
  • 网络营销培训机构排名seo关键词搜索和优化
  • 摄影网站建设论文个人小白如何做手游代理
  • 网站做系统的靠什么挣钱推广网站要注意什么
  • 网站建设案例展示佛山做网站建设
  • 如何做交友网站河北seo基础教程
  • 温州网站建设推广专家百度账号快速注册入口
  • 河北项目网是真实的吗深圳seo顾问
  • 动力无限西安网站建设网络营销运营策划
  • 如何利用电商平台推广推广优化网站排名
  • 在婚纱店做网站优化电脑培训网
  • 成都微信小程序分类信息开发上海站群优化公司
  • 广东的一起做网站seo推广优化培训
  • 无锡高端网站开发seo做的比较牛的公司
  • php wordpress apache关键词排名优化技巧
  • 崇文网站建设刚出来的新产品怎么推
  • 网站建设河南网络软文推广案例
  • 口腔网站模板网络营销需要学什么
  • 医院网站建设医生需要做什么深圳搜狗seo