这是一个由三部分组成的问题,我对。。。。在
我的输出没有给我输入整数的选项,它在下一行打印“none”并跳过该选项
结束文件触发器工作不正常
计算我为之记录数据的玩家……我真的不知道从哪里开始计算输入数据
---------------我的输出---------------------- 你将被要求输入球员的名字和分数 如果没有其他名称,请输入End
输入玩家姓名或结束退出程序:Randy 输入Randy的高尔夫得分: 无 ------------------我的输出端------------------
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个玩家记录写入高尔夫.txt在
-----------结束分配输出-----------------
应改为
^{pr2}$在python中打开和关闭文件的有效方法如下:
当循环完成时,使用with open方法将为您关闭文件。在
这里不需要使用
print
。在用这个
^{pr2}$试试这个:
相关问题 更多 >
编程相关推荐