Nick Rizzolo
Nick Rizzolo

Reputation: 125

How do I get this file to be read as a variable?

Using python 3.6.1

Encountered an error stating:

No such file or directory.

x = open(r'c:/Users/name/Desktop/CommercialArticles.txt/3_Biotech/3_Biotech\#1.txt', 'r'); 

This is the path given when I drop the file in terminal

Upvotes: 0

Views: 30

Answers (2)

user4340135
user4340135

Reputation:

CommercialArticles.txt is a file. You cannot go further inside a file to find more files/folders. So your path is incorrect.

After you fix it, you should also use "\\" instead of "/" while specifying the path.

Upvotes: 1

Rahul
Rahul

Reputation: 11560

Your file path is totally wrong. In windows press SHIFT and then Right Mouse Click on file will show you context menu. Select Copy as path option and the file path will be in clipboard. In terminal Right Mouse Click will paste the file path.

Upvotes: 1

Related Questions