文件读写(一行一行)
`# 写入文件
with open("test.txt", "w") as f:
f.write("第一行\n第二行")
读取并打印
with open("test.txt", "r") as f:
for line in f:
print(line.strip())`
知识点: 打开文件、读取行、写入新文件
`# 写入文件
with open("test.txt", "w") as f:
f.write("第一行\n第二行")
with open("test.txt", "r") as f:
for line in f:
print(line.strip())`
知识点: 打开文件、读取行、写入新文件