I'm making a program for saving passwords (only for me)
with open(file, mode='w', encoding='Latin-1') as FA:
try:
FAJ = json.load(FA)
except Exception:
tafa = {tarr[0]: {'login': tarr[1], 'password': tarr[2]}}
json.dump(tafa, FA)
else:
FAJ[tarr[0]] = {'login': tarr[1], 'password': tarr[2]}
json.dump(FAJ, FA)
finally:
FAJ.close()
time.sleep(1.5)
os.system('pause')
menu()
I'm trying to catch an error and check if the file is empty. But even if file is not empty it anyways throws exception. Does anyone know what could be a problem?