需求:在一个数据文件中,让用户输入信息 with open(r'bd.py',mode='rt',encoding='utf-8') as f: count=0 while count<=3: name=input("please input account: ") password=input("please input password: ") for msg in f: if name == msg.strip('\n').split(':')[0] and password == msg.strip('\n').split(':')[1]: print("login successful") break else: print("sb") count+=1