Open wanghaisheng opened 2 years ago
3.when i change
def read(self,key) -> dict:
for key, value in self.__dict.iteritems():
print(key, value)
with self.__lock:
try:
val = self.__dict[key]
print(222,val)
except:
# if key not in self.__dict:
print(111,self.__dict)
raise KeyError("error: given key does not exist in database. Please enter a valid key") #raising a key error
else:
mydict = json.loads(self.__dict[key])
return mydict
output
dict exist
fastlane_category1 {"noteable": "", "hot": "", "gold": "", "mostview-six":
"", "mostview-year": ""}
222 {"noteable": "", "hot": "", "gold": "", "mostview-six": "", "mostview-year": ""}
fastlane_category1 {"noteable": "", "hot": "", "gold": "", "mostview-six":
"", "mostview-year": ""}
222 {"noteable": "", "hot": "", "gold": "", "mostview-six": "", "mostview-year": ""}
555 {'noteable': '', 'hot': '', 'gold': '', 'mostview-six': '', 'mostview-year': ''}
if comment
for key, value in self.__dict.iteritems():
# print(key, value)
pass
error shows up again with key not exist
1.
2.