If FileNotFoundError occurs, the file is missing.
I ran os.remove("test1.txt")
so I only gave you the file name. Where should I erase "test1.txt"? You have to be curious about this.
In Windows, when a process runs, the execution position of the process is set. You can check the name current directory with a tool like processxp. If you click python idle and run it, the user does not clearly know where the current execution location is. But there is.
If you just give it a file name, it's going to work by searching for a file in this current directory.
© 2024 OneMinuteCode. All rights reserved.