我想从用户输入变量“名称”,然后我想将account.zk
(这是一个普通的文本文件)加载到一个列表中,然后我想检查输入是否已经在这个列表中. 如果不是,我想添加它,相反,我想跳过并继续。
我自己编写了这个函数,但我没有成功!有人能理解为什么吗?
# Start Downloading System
name = input(Fore.WHITE+"Enter Profile Name To Download: ")
# Save Account (used for check the updates!)
file_object = open("account.zk", "r")
for line in file_object:
stripped_line = line.strip()
line_list = stripped_line.split()
list_of_lists.append(line_list)
if (len(list_of_lists) != len(set(name))):
print("\n\nAlready in List!\n\n")
file_object.close
time.sleep(5)
else:
file_object.close
file_object = open("account.zk", "w")
file_object.write(name + "\n")
file_object.close