i need to take the user input from the text boxes and put it into my dict. my code is this but i seem to get keyerror.,
my_Dict = {}
v = self._etyV.get() # vehicle number
n = self._etyN.get() # time in
in, out, charge = m_Dict
this is to append into my_Dict with v as the key and in as value. but since time out and charge is not recorded yet it will just take as None.
my_Dict[v] = {in, None, None}
I believe the answer you are looking for is
my_Dict.update({v : [time_in, None, None]})
Also for future reference the word in
is a reserved keyword in python, not sure if you were aware.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.