code
f = open('a.txt', 'r') n = open('b.txt','w+') n.writelines(f.readlines()) n.close() f.close()
code
f = open("a.txt", 'w') f.write("写入一行新数据") f.flush()
code
f = open("a.txt", 'w',buffering = 0) f.write("写入一行新数据")
code
f = open("a.txt", 'w') f.write("写入一行新数据") f.close()
code
f = open("a.txt", 'a') f.write(" 写入一行新数据") f.close()