os.remove()FileNotFoundError Error

Asked 1 years ago, Updated 1 years ago, 120 views

Like #3, I learned that os.remove('file name') deletes it, but it says that there is no file or there is a type error.

I want to know how to delete test1.txt as os.remove.

test1txt is a file created in #1 and moved in #2.

remove module python

2022-09-20 16:26

1 Answers

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.


2022-09-20 16:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.