我已经试着让这个程序运行大约30分钟了,但是每次我运行这个文件时,它都会在任何类型的输入后自动退出。 我不知道问题出在哪里,所以我将发布所有代码。 以下是我到目前为止的情况:
import os, time
os.system("color")
loading = 0
logged = 0
r = "r"
l = "l"
COLOR = {
"PURPLE": "\033[95m",
"BLUE": "\033[0;34m",
"GREEN": "\033[0;32m",
"RED": "\033[91m",
"GRAY": "\033[0;39m",
"CYAN": "\033[0;36m",
"CLR": "\033[0m",
}
print(COLOR["GRAY"], "starting", COLOR["CLR"], "\bSh", COLOR["CYAN"], "\b\bi", COLOR["CLR"], "\b\bftOS...")
while loading <= 10:
for rod in r'--//||\\':
print(rod, rod, rod, rod, rod, rod, rod, rod, rod, rod, rod, end='\r')
time.sleep(0.05)
loading = loading + 1
###############################
yesno = input("register or login? (r/l) -> ")
if yesno == r: register_a()
if yesno == l: log_in()
# if yesno != "r" and yesno != "l": quit()
def register_a():
print(COLOR["BLUE"], "\n\n new username: ", COLOR["CLR"])
username = input("-> ")
print(COLOR["RED"], "\n\n new password: ", COLOR["CLR"])
password = input("-> ")
print("writing credentialz.txt file..")
f = open("credentialz.txt", "w")
f.write(username)
f.close()
f = open("credentialz.txt", "a")
f.write(password)
f.close
return username, password
def log_in():
f = open("credentialz.txt", "a")
a = f.readline()
b = f.readline()
f.close
useratt = input("USERNAME: ")
passatt = input("PASSWORD: ")
f = open("credentialz.txt", "r")
if useratt == a and passatt == b:
print(COLOR["BLUE"], "LOGGED IN SUCCESSFULLY!", COLOR["CLR"])
logged = 1
else:
print(COLOR["RED"], "WRONG USERNAME/PASSWORD!", COLOR["CLR"])
我正在Windows10上使用Python3.9
在
log_in()
函数中,尝试写入f.close()
。你错过了括号相关问题 更多 >
编程相关推荐