【发布时间】:2017-07-05 21:08:52
【问题描述】:
我已经为我的 GCSE 课程作业制作了一个程序,需要一些关于将所有用户输入保存到记事本中的文本文件的帮助,如果有任何帮助,将不胜感激
代码是
print("Use Yes Or No For Answers That Require It")
from datetime import datetime #imports time package count=0 #sets count to 0
while True:
count +=1
if count >3:
break
name=input("what is your name\n")
yob=int(input("what is your yob\n"))
year = datetime.now().year #sets year
age=year-yob # sets age as a constant
print("so you are",age,)
user_input=input ("is this correct\n")
if user_input==("yes"):
print("nice")
else:
print("oops, you must be",age-1)
【问题讨论】:
-
你有没有尝试过?喜欢
inputFile = open("inputs.txt", 'w')然后写信给它?你在使用图书馆吗?您如何获得用户输入? -
print("对需要它的答案使用是或否") from datetime import datetime #imports time package count=0 #sets count to 0 while True: count +=1 if count >3: break name=input("what is your name\n") yob=int(input("what is your yob\n")) year = datetime.now().year #sets year age=year-yob # 设置年龄作为常量 print("so you are",age,) user_input=input ("is this correct\n") if user_input==("yes"): print("nice") else: print("oops, you必须是",age-1)
-
这是程序的代码,我不知道如何保存到文本文件
-
你能编辑一下代码,然后发回我电脑上的文本文件名为 data_file
-
如您所知,我对 Python 编程很陌生
标签: python-3.5