编写游戏,无论我尝试什么,都会不断给我“ as”的语法错误。
我尝试查看StackOverflow /更改代码以找到解决方法,但到目前为止,我仍无法修复它
winner = input("Winner test username")
winnerscore = input("Test score")
open("leaderboardtest.txt","a") as leaderboard
leaderboard.write = "/n" , winner , " : " , winnerscore
(获胜者和获胜者得分变量早些时候就已经制作出来了,只是在测试过程中在此处写下)
无效的语法突出显示为“ as”。
(我知道这是StackOverflow上其他事物的一个相对简单的问题,但我会提供任何支持。)
最佳答案
你去。
winner = input("Winner test username")
winnerscore = input("Test score")
with open("leaderboardtest.txt","a") as leaderboard:
string_to_write = "\n" + winner + " : " + winnerscore
leaderboard.write(string_to_write)