database - Python. "Need more than one value to unpack" -
def store_infile(name,address,area,postcode): #open file file2 = open("fines.txt","rt") #write name address , post code file , save file file2.write(str(name)+"\n"+str(address)+"\n "+str(area)+"\n "+str(postcode));file2.close() #set file open datatbase file =open("database.txt","rt") nump_input = str(input("number plate of person speeding. ").upper()) #loop each line intil numberplate gets match line in file: numberplate,name,address,area,postcode = line.split("|") #here use whatever have splitting database ie , . / ( | if nump_input.upper() == numberplate: #output name address , number plate print("fine sent \n \n"+str(name)+"\n"+str(address)+"\n "+str(area)+"\n "+str(postcode));store_infile(name,address,area,postcode)
i want read database , if user enters number plate associated database information(parameters) sent file.
check input - file "database.txt". there's line
not have "|" in it, not "splitted 5 parts" code demands:
numberplate,name,address,area,postcode = line.split("|")
example:
>>> line = "hello, world" >>> numberplate,name,address,area,postcode = line.split("|") traceback (most recent call last): file "<stdin>", line 1, in <module> valueerror: need more 1 value unpack
Comments
Post a Comment