【发布时间】:2016-10-02 03:52:38
【问题描述】:
这是一个由三部分组成的问题,我遇到了问题......
我的输出没有让我选择输入我的整数,它在下一行打印“none”并跳过该选项
结束文件触发器无法正常工作
计算我为其记录数据的球员......老实说,我不知道从哪里开始计算输入
--------我的输出---------- 您将被要求输入球员姓名和分数 当你没有更多的名字时,输入 End
输入玩家姓名或结束退出程序:Randy 输入 Randy 的高尔夫分数: 没有任何 ------------------我的输出END--------------------
我的代码;
def main():
#introduction to user explaining required information to be entered
print("You will be asked to enter players names and scores")
print("When you have no more names, enter End")
#double blank space
print("\n")
#defined y/n
anotherPlayer = "y"
#define file path to save user input
usersFile = open('golf.txt', 'w')
#
while anotherPlayer == "y":
playerName = input("Enter Player's Name or End to exit program: ")
score = int(input(print("Enter", playerName, "'s golf score: ")))
usersFile.write(playerName + "," + str(score) + "\n")
anotherPlayer = input("Is there another player? y / End: ")
End = usersFile.close()
main()
-----------------结束我的代码--------------------
我需要它说出来;
---------需要赋值输出------
您将被要求输入球员姓名和分数 当你没有更多的名字时,输入 End
输入玩家姓名或结束退出程序:Randy 输入 Randy 的高尔夫分数:50
输入玩家姓名或结束退出程序:结束 您已将 1 条球员记录写入 golf.txt
---------结束赋值输出----
【问题讨论】:
-
请修复代码中的缩进
-
我认为我做得对吗?