#coding:utf-8 #Author:Mr Zhi file_open = open('购物车用户信息','r+',encoding="utf-8") #购物车用户信息文件保存着用户名密码和余额 f = str(file_open.read()) for line in f: file_str = str(f) file_open_dict = eval(file_str) #转换成字典(文件内容原先是字典) username = input("输入用户名:") password = input("输入密码:") while True: if username in file_open_dict: #判断用户名是否在购物车用户信息文件中 if password in file_open_dict[username]: salary = int(file_open_dict[username][password]) print('''