2024-06-01 01:20:18 发布
网友
我正在使用tkinter,每当我按下按钮时,我都想在文件中写入一个字符串。 但是,因为我可以从tkinter条目小部件更改字符串,所以在文件中只写入最后一个字符串。 如何将tkinter中的每个字符串以不同的行写入并保存到文件中
with open("Accountdata.txt", "r+") as f: f.write(str(usernames)) f.write("\n") print(f.read()) f.close()
with open(filename, 'a+') as f: # append (plus) mode f.write(str(usernames) + '\n') f.seek(0) print(f.read())
相关问题 更多 >
编程相关推荐