Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 16714

Reading a file in python macOS [duplicate]

$
0
0

So basically, I'm new to coding and I'm trying to read the contents of a .txt file and I'm able to do that by hardcoding the file path of the .txt file but I'm trying to write lines of code where it accesses it without having to hardcode it.

First I placed the .txt file in the same folder as the python file where I was working on my code on vscode on macOS but I'm given the error "No such file or directory". I then hardcoded the file path instead of the .txt file name and then it worked.


Viewing all articles
Browse latest Browse all 16714

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>