Ask coding questions

← Back to all posts
why I get an error message when i try to read txt file from my desktop?
ronentagger (0)

why I get an error message when i try to read txt file from my desktop?

Answered by Wumi4 (458) [earned 5 cycles]
View Answer
Wumi4 (458)


You just have some mistakes in your problem:

  • First, you haven't upload the file vacation.txt yet. Make sure that you have created the file with the same name or upload it just by drag and drop!
  • Second, you should know that you are using, it isn't your computer, and don't have permission to access file in your computer, so, replace the first line:
one = open( r"D:\Users\rtagger\Desktop\vacation.txt", "r")


one = open( r"./vacation.txt", "r")
  • Third, why would you need an r before the strings on the first line?

I can be pretty strict, but did you know that the r before the string means that This string is a Regex rule? So, remove it, it's unnecessary:


Now, I bet that you will get a much better code! :)

ronentagger (0)

@Wumi4 Thank you for you answer.
I didn't Know that do not have access to my computer files.
now it is working for me. :)


For one thing doesn't support those kind of files. You might want to use normal files like file.txt. So you also have to make the file first if you are using read mode.

one = open"file.txt", "r")
all_one =

now you have to make file.txt. And after you do that. If you are in read mode, you can write something in that file, and when you run it. The console will read the file.
That should work