Python-匹配来自外部文件的数据(用户名密码)

时间:2019-12-12 12:55:25

标签: python external

我知道这与换行标记有关,但是为什么我的程序在我的外部文件中找不到用户名/密码匹配?

username = input("Please enter your username: ")
password = input("Please enter your password: ")
file = open("UsernamesPasswords.txt", "r")
for loop in file:
    line = file.readline()
    data = line.split(",")
    print(data)
    if username == data[0] and password == data[1]:
        print("That's a match")
    else:
        print("That's not a match!")
        break
file.close()

1 个答案:

答案 0 :(得分:0)

假设import streamlit as st x = 1 if st.button("Increment x"): x=x+1 st.text(x) 看起来像这样:

UsernamesPasswords.txt

我们可以编写代码:

username_1,password_1
username_2,password_2
username_3,password_3