# 文件的后缀名
# 打开 open(文件名,访问模式),默认访问模式"r",read
# f = open("王者","r")
# # 读 read
# content = f.read()
# print(content)
# # 关闭文件
# f.close()
# # 写入文件 写入的访问模式 "w"
# f = open("王者","w")
# # 写 write
# f.write("wo_xiang_xie_emmemm")
# f.close()
# d = open("王者荣耀.txt","w")
# d.write("wang")
# d.close()
# dd = open("王者","r+")
# content = dd.read()
# print(content)
# dd.write("信心")
# dd.close()
# 设置语句 with 和 ,用
# with open("王者","r+") as f:
# c = f.read()
# print(c)
# f.write("武汉必胜")
# 复制,拿出来====》 读取文件内容
# 粘贴,写进去====》 写入文件内容
# f1 = open("王者","r")
# c = f1.read()
#
# f2 = open("王者荣耀.txt","w")
# f2.write(c)
#
# f1.close()
# f2.close()
with open("王者","r+") as f1,open("王者荣耀.txt","w") as f2:
c = f1.read()
f2.write(c)
xinxin -王者荣耀以及写入和读取文件
最新推荐文章于 2021-05-29 11:13:36 发布