0
即时通讯新的ish到python和ive得到了这段代码,我希望它允许在输入时随时输入“退出”一词。一旦完成,它会关闭脚本。从循环python退出3
任何帮助将非常感激。
import sys
while True:
def inputs():
first=input("Enter your first name: ")
last=input("Enter your last name: ")
gender=input("Enter your gender: ")
form=input("Enter your form: ")
file = open("signup.txt", "a")
#Records the user's details in the file
file.write("\nFirst name: "+first+", Last name: "+last+", Gender: "+gender+", Form: "+form)
#Closes the file
file.close()
if input(inputs) == "exit":
sys.exit()
inputs()
这里没有循环。 –