mode="r" 和 函数末尾调用 regist()!!!!

时间:2023-08-18 17:26:47
def regist():
f = open(r"G:\课件\day09 初始函数\code\day009 初始函数\account", mode="r", encoding="utf-8")    # 注意mode="r"还是"r+",容易错!!!!!!!
while 1:
username = input("请输入用户名:")
password = input("请输入密码:")
for line in f:
if username == line.strip().split(":")[0]:
print("用户已经注册")
break
else:
print("恭喜,注册成功")
f.write("\n" + username + ":" + password)
f.flush()
f.close()
return regist()      # -->没写这个,上面所有的白写!!!!!!!