我无法将设置为字符串数据类型的整数集的数据存储到文本文件中。没有错误代码出现
我尝试将数据类型设置为str,什么也没发生
difference = (p2_total) - (p1_total)
print (p1_name , " was " , difference , " points away from drawing ")
winner = 'p2'
loser = 'p1'
#states who wins and by how much
difference = str(difference)
Ending = (winner , "won the match with a " , difference , "point leadon",
loser)
Ending = str(Ending)
print (Ending)
store = input("Would you like to store this game? (Y/N) ")
if store == ("Y"):
f.write(str(Ending))
f.close
elif store == ("N"):
print ("You kinda have to.... so im going to do it anyways. sorry :)")
f.write(Ending)
f.close
else:
print("Invalid Answer. Try again!")
while store == ("Y") or store == ("N"):
f.write(str(Ending))
f.close
预期结果是文本文件包含代码将放入的数据 结果是文本文件仍然为空并且没有错误出现