file = open("My File.txt",'a+')
for i in range(0,5):
cdtitle = input("Enter CD Title: ")
while cdtitle != "##":
cdartist = input("Enter CD artist: ")
cdlocation = input("Enter CD location: ")
file.append(cdtitle-----cdartist-----cdlocation)
file.close()如何编写特定程序的输出并使用python将其保存在文件中?
> 据我
其中*特别节目*? –
你使用file.write(some_string),而不是追加... – Copperfield
你也陷入了死循环,因为你不会在'while'循环中改变'cdtitle' – MooingRawr