我想知道如何将文本文件的多行与单个变量进行比较。我已经部分工作了,但它只与文本文件的最后一行进行比较
def loginSetup():
global loginSelector
global accountInt
loginSelector = int(input("Select Action:"))
if loginSelector == 1:
#login
print ("action complete")
if loginSelector == 2:
#sign up
accountInt = int(input("Input 4 Digit Pin:"))
while (accountInt >= 9999 or accountInt <= 999):
print("ERROR\nTry Again")
accountInt = int(input("Input 4 Digit Pin:"))
accountInt = str(accountInt)
with open('Account.txt', 'r') as rf:
for line in rf:
if (line == str(accountInt)):
print("error")
with open('Account.txt', 'a') as f:
f.write('\n')
f.write(accountInt)
while True:
loginSetup()
BIG阳
相关分类