Я пытаюсь прочитать текстовый файл '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
Filenotfounderror при попытке прочитать и написать текстовый файл ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение