FilenotFoundError beim Versuch, eine Textdatei zu lesen und zu schreibenPython

Python-Programme
Guest
 FilenotFoundError beim Versuch, eine Textdatei zu lesen und zu schreiben

Post by Guest »

Ich versuche, die Textdatei 'todos.txt' mit dem Verschieben von todos.txt in einen neuen Ordner namens Dateien zu lesen. Ich empfange einen Fehler: < /p>

Code: Select all

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  < /p>
[code]FileNotFoundError: \[Errno 2\] No such file or directory: 'todos.txt

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post