欢迎使用堆栈溢出!你用什么把你的高分存储在python中?一门课,一本字典?
要简单地将字符串内容写入文件,可以执行以下操作:
scores = [('username1', 123), ('username2', 456)] with open('scores.txt', 'w') as f: for username, score in scores: f.write('Username: {0}, Score: {1}\n'.format(username, score))