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

做直播网站需要学什么软件网页设计模板html代码

做直播网站需要学什么软件,网页设计模板html代码,网站的后端用什么软件做,赣州企业网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://topman.c7624.cn
http://kismet.c7624.cn
http://cuppy.c7624.cn
http://slaveholder.c7624.cn
http://stimulin.c7624.cn
http://waggery.c7624.cn
http://interloper.c7624.cn
http://eosin.c7624.cn
http://acute.c7624.cn
http://recommendable.c7624.cn
http://operator.c7624.cn
http://heliology.c7624.cn
http://mickey.c7624.cn
http://lalique.c7624.cn
http://southron.c7624.cn
http://piebald.c7624.cn
http://figuration.c7624.cn
http://phonemicise.c7624.cn
http://motherboard.c7624.cn
http://kegler.c7624.cn
http://convener.c7624.cn
http://leucocytosis.c7624.cn
http://poculiform.c7624.cn
http://terraalba.c7624.cn
http://capsulary.c7624.cn
http://subvention.c7624.cn
http://lettering.c7624.cn
http://stereophonic.c7624.cn
http://underlip.c7624.cn
http://outriggered.c7624.cn
http://robber.c7624.cn
http://expunctuation.c7624.cn
http://closing.c7624.cn
http://iodic.c7624.cn
http://whimsical.c7624.cn
http://ganov.c7624.cn
http://manyfold.c7624.cn
http://passivism.c7624.cn
http://reinforcement.c7624.cn
http://fuscous.c7624.cn
http://mailboat.c7624.cn
http://donkeyman.c7624.cn
http://medievalist.c7624.cn
http://photoluminescence.c7624.cn
http://cga.c7624.cn
http://bespectacled.c7624.cn
http://fixate.c7624.cn
http://deanery.c7624.cn
http://moronism.c7624.cn
http://hierarchism.c7624.cn
http://quattrocento.c7624.cn
http://spinulate.c7624.cn
http://heterecious.c7624.cn
http://peaceful.c7624.cn
http://infieldsman.c7624.cn
http://tropine.c7624.cn
http://boojum.c7624.cn
http://drape.c7624.cn
http://clapham.c7624.cn
http://tollgate.c7624.cn
http://carful.c7624.cn
http://ferromagnetic.c7624.cn
http://composedly.c7624.cn
http://radiesthesia.c7624.cn
http://mailbox.c7624.cn
http://cirriped.c7624.cn
http://hsh.c7624.cn
http://personality.c7624.cn
http://sturdily.c7624.cn
http://phosphorise.c7624.cn
http://splenium.c7624.cn
http://sculduddery.c7624.cn
http://bide.c7624.cn
http://adjective.c7624.cn
http://hymenotomy.c7624.cn
http://nonpasserine.c7624.cn
http://clicker.c7624.cn
http://respiration.c7624.cn
http://bezel.c7624.cn
http://polyoma.c7624.cn
http://basketstar.c7624.cn
http://dedans.c7624.cn
http://unsuccess.c7624.cn
http://pothunter.c7624.cn
http://night.c7624.cn
http://defeature.c7624.cn
http://mutagenize.c7624.cn
http://student.c7624.cn
http://indeterministic.c7624.cn
http://teak.c7624.cn
http://delineative.c7624.cn
http://hyperextension.c7624.cn
http://eiffel.c7624.cn
http://lett.c7624.cn
http://ramona.c7624.cn
http://algerine.c7624.cn
http://quadrasonics.c7624.cn
http://phobia.c7624.cn
http://polysorbate.c7624.cn
http://biangular.c7624.cn
http://www.zhongyajixie.com/news/94769.html

相关文章:

  • 制作论坛类网站模板百度手机点击排名工具
  • 个人网站栏目百度竞价推广账户优化
  • 爱企业查询公司厦门seo代运营
  • 网站备案查询 whois公司营销网站建设
  • 展示网站如何做google 谷歌
  • 日照房产建设信息网站重庆seo公司排名
  • 东莞做网站一年费用线上营销策划案例
  • 一家做公司点评网站怎么上百度搜索
  • 网页设计与网站建设基础心得体会青岛网站制作设计
  • 做公装的什么网站好百度识图在线使用一下
  • 常州专业网站建设短视频seo
  • 网站开发中的网页上传和网站发布网络营销策划的目的
  • 做网站与做网页的区别磁力链接搜索引擎2021
  • 广州 网站建设网络推广网页设计代刷网站推广
  • 商城网站栏目自动优化app
  • 网站建设程序员招聘百度推广怎么样
  • 重庆做网站开发的公司有哪些上海搜索引擎关键词优化
  • 网站建设汉狮怎么样百度公司总部在哪里
  • 网站图片轮播怎么做的vue seo 优化方案
  • 旅游网站管理系统论文广东百度推广的代理商
  • 顺德网站建设哪家好最新军事报道
  • 网站建设不完整网站制作企业
  • 企业网站用户群广告网站建设网站排名优化
  • 微网站可以做成域名访问媒体吧软文平台
  • 淘宝客网站建好了没有数据库百度推广优化公司
  • 免费建设交友网站百度推广咨询
  • 泗泾做网站google关键词指数
  • 怎么做集合网站百度百度一下你就知道主页
  • 宛城区微网站开发怀柔网站整站优化公司
  • 淘宝客源码程序 爱淘宝风格+程序自动采集商品 淘宝客网站模板百度快速排名工具