我有两个错误,无法解决。
第一个是:
json.decoder.JSONDecodeError:预期值:第1行第1列(字符0)。
第二个是:
KeyError [“数据字节1:”]
def save_details():
global details
with open("customerDetails.json", "wb+") as customer_details: #open customerDetails.json
details = {
"Data Bytes 1: ": username,
"Data Bytes 2: ": user_phone_number,
"Data Bytes 3: ": user_password
}
customer_details.write(base64.b64encode(json.dumps(details).encode()))
with open("customerDetails.json", "rb") as customer_details:
details = json.loads(base64.b64decode(customer_details.read()).decode())
customers = json.loads(base64.b64decode(open("customerDetails.json", "rb").read()))
if username == customers["Data Bytes 1: "] and user_password == customers["Data Bytes 3: "]:
print("\nLogin in Successful! ")
else:
print("\nThere is trouble logging in, please try again.\n ")
cancel_order() '''
这是我的代码的一部分,与此问题相关。
有没有人知道如何解决此问题?
答案 0 :(得分:0)
'''
with open("customerDetails.json", "rb") as customer_details:
details = json.loads(base64.b64decode(customer_details.read()).decode())
if username == details["Data Bytes 1: "] and user_password == details["Data Bytes 3: "]:
print("\nLogin Successful! ") '''