elif menuOption == "2":
with open("Hotel.txt", "a+") as file:
print (file.read())
我尝试了很多不同的方法,但我的 python 文件只是拒绝打印 txt 内容。它正在写入文件,但选项 2 不会读取它。
if menuOption == "1":
print("Please Type Your Guests Name.")
data1 = (input() + "\n")
for i in range (2,1000):
file = open("hotel.txt", "a")
file.write(data1)
print("Please Write your Guests Room")
data2 = (input("\n") + "\n")
file.write(data2)
data3 = random.randint(1, 999999)
file.write(str (data3))
print("Guest Added - Enjoy Your Stay.")
print("Guest Name is:", data1)
print("Guest Room Number Is:", data2)
print("Your Key Code Is:", data3)
我希望将上述所有信息添加到 TXT。(那有效)然后也可以阅读它。这是行不通的。为什么以及如何修复?
墨色风雨
江户川乱折腾
相关分类