我正在制作一个程序,可以让您在 python 中编辑或阅读文本文档,但我还没有完成,我被困在阅读部分。我希望它只打印一行,而我正在为如何做到这一点画一个空白。读取部分在“def read():”中
def menu():
print("What would you like to do?")
print("\n(1) Write new text")
print("(2) Read line 3")
choice = float(input())
if choice == 1:
write()
elif choice == 2:
read()
def read():
with open('test.txt', 'r') as read:
print()
def write():
print("\nType the full name of the file you wish to write in.")
file1 = input().strip()
with open(file1, "a") as add:
print("What do you want to write?")
text = input()
add.write("\n"+ text)
menu()