Filenotfounderror при попытке прочитать и написать текстовый файлPython

Программы на Python
Anonymous
 Filenotfounderror при попытке прочитать и написать текстовый файл

Сообщение Anonymous »

Я пытаюсь прочитать текстовый файл 'todos.txt' с перемещением todos.txt в новую папку с именем файлов.

Но теперь я не могу открыть этот файл и когда я запускаю свой код, Я получаю ошибку: < /p>
while True:
user_action = input("Type add, show, edit, complete, or exit: ").strip()

with open('todos.txt', 'r') as file:
todos = file.readlines()

match user_action:
case 'add':
todo = input("Enter a todo: ") + "\n"
todos.append(todo)

case 'show':
for index, item in enumerate(todos):
item = item.title()
print(f"{index + 1}-{item}", end='')

case 'edit':
number = int(input("Number of the todo to edit? ")) - 1
new_todo = input("Enter new todo to replace: ")
todos[number] = new_todo + "\n"

case 'complete':
number = int(input("Number of the todo to complete? ")) - 1
if 0
FileNotFoundError: \[Errno 2\] No such file or directory: 'todos.txt


Подробнее здесь: https://stackoverflow.com/questions/793 ... a-textfile

Вернуться в «Python»