我试图创建一个非常基本的小操作系统,只是为了好玩,使用Python。到目前为止,我有这样的:如何将输入保存到文件,然后检查文件中的输入?
rUsername = input("Create a new user: ")
rPassword = input("Create a password for the user: ")
tUsername = input("Username: ")
def username():
if tUsername != rUsername:
print("User not found.")
blank = input("")
exit()
username()
def password():
if tPassword != rPassword:
print("Incorrect password.")
blank = input("")
exit()
tPassword = input("Password: ")
password()
def typer():
typerCMD = input("")
print ("Hello, and welcome to your new operating system. Type 'help' to get started.")
shell = input("--")
if shell == ("help"):
print("Use the 'leave' command to shut down the system. Use the 'type' command to start a text editor.")
shell2 = input ("--")
if shell2 == ("leave"):
print("Shutting down...")
exit()
if shell2 == ("type"):
typer()
但我想程序运行,这样它会创建的用户名保存到一个文件,这样你就不必每次运行时创建一个新的用户名。有小费吗? (请不要评判我对我的“文本编辑器。”这就是那里,以便有一个目的,在签订)。