【发布时间】:2022-11-27 17:22:09
【问题描述】:
所以我写了这段代码,我希望计算机打开一个文件并在其中写入用户对我问他的问题的回答,但是当我打开 txt 文件时它是空的。
import os
Welcome = input("Hi my name is Steve. Do you have an account at Steve? ANSWER WITH JUST A YES OR NO ")
def register():
name = input("First name: ")
last_name = input("Last name: ")
Email = input("Email: ")
ussername = input("Username: ")
password = input("Password: ")
def login():
ussername = input("Username: ")
password = input("Password: ")
if Welcome == "yes":
login()
else:
register()
if Welcome == "no" or "No":
with open("userinfo.txt", "w") as file:
file.write(register())
【问题讨论】: