一、基础程序
import os
# import easygui as g
f = open("a.docx", 'w')#docx可换为txt
f.close()
os.remove("a.docx")
# l=g.enterbox("你终于离开了,请写下你的评价",title="猜数字游戏")
time=int(input("你要输入几行?"))
f = open("a.docx", 'w')
l=input()
print("你的输入是:",l)
f.close()
n1=l
f = open("a.docx", 'a')
f.write(n1)
while time-1>0:
time=time-1
l=input()
print("你的输入是:",l)
f.close()
n1="\n"+l
f = open("a.docx", 'a')
f.write(n1)
f.close()
print("输出成功")
二、进阶
import os
# import easygui as g
f = open("a.docx", 'w')
f.close()
os.remove("a.docx")
# l=g.enterbox("你终于离开了,请写下你的评价",title="猜数字游戏")
# time=int(input("你要输入几行?"))
f = open("a.docx", 'w')
l=input()
print("你的输入是:",l)
f.close()
n1=l
f = open("a.docx", 'a')
f.write(n1)
while l!="end":
# time=time-1
l=input()
print("你的输入是:",l)
f.close()
n1="\n"+l
f = open("a.docx", 'a')
f.write(n1)
f.close()
print("输出成功")
import os
# import easygui as g
f = open("a.docx", 'w')
f.close()
os.remove("a.docx")
print("输入end结束")
# l=g.enterbox("你终于离开了,请写下你的评价",title="猜数字游戏")
# time=int(input("你要输入几行?"))
f = open("a.docx", 'w')
l=input()
print("你的输入是:",l)
f.close()
n1=l
f = open("a.docx", 'a')
f.write(n1)
while l!="end":
# time=time-1
if l!=end:
l=input()
print("你的输入是:",l)
f.close()
n1="\n"+l
f = open("a.docx", 'a')
f.write(n1)
f.close()
print("输出成功")