Fork me on GitHub
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 23 下一页
  2020年3月18日
摘要: # 1、写函数,,用户传入修改的文件名,与要修改的内容,执行函数,完成批了修改操作'''import osdef file(file,old,new): with open(file,mode='rt',encoding='utf-8') as f1,open('files.txt',mode='w 阅读全文
posted @ 2020-03-18 14:27 OBOS 阅读(255) 评论(0) 推荐(0)
摘要: # 一 形参与实参介绍# 形参:在定义函数阶段定义的参数称之为形式参数,简称形参,相当于变量名# def func(x, y): # x=1,y=2# print(x, y)# 实参:在调用函数阶段传入的值称之为实际参数,简称实参,相当于变量值# func(1,2)# 形参与实参的关系:# 1、在调 阅读全文
posted @ 2020-03-18 12:52 OBOS 阅读(154) 评论(0) 推荐(0)
  2020年3月17日
摘要: # 1、编写文件修改功能,调用函数时,传入三个参数(修改的文件路径,要修改的内容,修改后的内容)既可完成文件的修改'''import osdef file(d,old,new): with open(d,mode='rt',encoding='utf-8') as f1,open('n.txt',m 阅读全文
posted @ 2020-03-17 16:50 OBOS 阅读(224) 评论(0) 推荐(0)
摘要: 文件的两种修改方式 # with open('a.txt',mode='r+t',encoding='utf-8') as f:# f.seek(9,0)# f.write('<男妇女主任>')# 文件修改的两种方式# 方式一:文本编辑采用的就是这种方式# 实现思路:将文件内容发一次性全部读入内存, 阅读全文
posted @ 2020-03-17 16:47 OBOS 阅读(369) 评论(0) 推荐(0)
  2020年3月16日
摘要: #1、通用文件copy工具实现'''file1=input('文件路径: ').strip()file2=input('文件路径: ').strip()with open(r'{}'.format(file1),mode='rb') as f1,open(r'{}'.format(file2),mo 阅读全文
posted @ 2020-03-16 17:18 OBOS 阅读(161) 评论(0) 推荐(0)
摘要: x模式 '''x模式(控制文件操作的模式)-》了解 x, 只写模式【不可读;不存在则创建,存在则报错】''''''# with open('a.txt',mode='x',encoding='utf-8') as f:# pass# with open('c.txt',mode='x',encodi 阅读全文
posted @ 2020-03-16 15:34 OBOS 阅读(269) 评论(0) 推荐(0)
  2020年3月13日
摘要: '''#一:今日作业:#1、编写文件copy工具file1=input('请输入文件路径:')file2=input('请输入文件路径:')with open(r'{}'.format(file1),mode='rt',encoding='utf-8') as f1,open(r'{}'.forma 阅读全文
posted @ 2020-03-13 14:34 OBOS 阅读(149) 评论(0) 推荐(0)
摘要: 文件与文件模式介绍 1、什么是文件 文件是操作系统提供给用户/应用程序操作硬盘的一种虚拟的概念/接口 用户/应用程序(open()) 操作系统(文件) 计算机硬件(硬盘)2、为何要用文件 用户/应用程序可以通过文件将数据永久保存的硬盘中 即操作文件就是操作硬盘 用户/应用程序直接操作的是文件,对文件 阅读全文
posted @ 2020-03-13 14:03 OBOS 阅读(147) 评论(0) 推荐(0)
  2020年3月12日
摘要: 集合 # 1、作用# 1.1 关系运算# friends1 = ["zero","kevin","jason","egon"]# friends2 = ["Jy","ricky","jason","egon"]# l=[]# for x in friends1:# if x in friends2: 阅读全文
posted @ 2020-03-12 17:30 OBOS 阅读(193) 评论(0) 推荐(0)
  2020年3月11日
摘要: '''1、有列表['alex',49,[1900,3,18]],分别取出列表中的名字,年龄,出生的年,月,日赋值给不同的变量'''# l=['alex',49,[1900,3,18]]# name=l[0]# age=l[1]# year=l[2][0]# month=l[2][1]# day=l[ 阅读全文
posted @ 2020-03-11 17:52 OBOS 阅读(146) 评论(0) 推荐(0)
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 23 下一页