首页 > 编程语言 >Python----文件操作练习题

Python----文件操作练习题

时间:2023-01-12 14:11:06浏览次数:50  
标签:练习题 utf encoding Python 作业 ---- txt open con

with open("./作业.txt", "w", encoding="utf-8") as w:
    w.write("晓出净慈寺送林子方\n毕竟西湖六月中\n风光不与四时同\n接天莲叶无穷碧\n映日荷花别样红")

with open("./作业.txt", "r", encoding="utf-8") as r:
    con = r.readlines()
    del con[1]

with open("./作业.txt", "w", encoding="utf-8") as w:
    w.write("".join(con))

with open("./作业.txt", "r", encoding="utf-8") as r:
    cont = r.read()
    print(cont)

 

标签:练习题,utf,encoding,Python,作业,----,txt,open,con
From: https://www.cnblogs.com/cenb/p/17046528.html

相关文章