简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM