Les entrées sont collectées dans la première fonction, disponible dans la deuxième fonction, mais je dois pouvoir tout ajouter au fichier texte. Il dit trop d'arguments, s'il vous plaît aider!trop d'arguments à ajouter au fichier txt
def newMember(): # gathers info to pass into sub routine to write to file
global surname, year, status, nights, points
print("Please enter the following information")
surname=input("Surname\n")
year=input("Year joined \n")
status=input("Membership status \n")
nights=input("Nights booked \n")
points=input("Points balance \n")
print("Please confirm these details \nSurname: "+surname+ "\nYear joined: "+year+ "\nMembership status: "+status+"\nNights booked: "+nights+ "\nPoints balance: "+points)
reply=input("Please type either Yes or No\n")
if reply in["Y","y","Yes","yes"]: #using an array in the selection to cover possible inputs
print("Thank you, these will now be written to file. Returning you to the main menu options") # write to file
time.sleep(3)
appendMember()
elif reply in ["n","N","no","No"]:
print("Sorry, you will now be prompted to enter the details again")
newMember()
else:
print("I'm sorry, I didn't quite catch that, the program will now restart")
newMember()
def appendMember():
global surname, year, status, nights, points
with open('SampleData2017.txt', mode="a")as crawdale:
crawdale.write[surname, year, status, nights, points]
Je ne sais pas pourquoi cela n'a pas été copié comme du code. C'est la dernière ligne qui est le problème si, un seul morceau de données, comme le nom de famille ajoutera, plus d'un ne sera pas –