This content originally appeared on DEV Community and was authored by Waylon Walker
When I need to read contents from a plain text file in python I find the easiest way is to just use Pathlib
.
from pathlib import Path
Path('path_to_file').read_text()
This content originally appeared on DEV Community and was authored by Waylon Walker
Print
Share
Comment
Cite
Upload
Translate
Updates
There are no updates yet.
Click the Upload button above to add an update.

APA
MLA
Waylon Walker | Sciencx (2022-03-20T22:37:37+00:00) How I read Files in Python. Retrieved from https://www.scien.cx/2022/03/20/how-i-read-files-in-python/
" » How I read Files in Python." Waylon Walker | Sciencx - Sunday March 20, 2022, https://www.scien.cx/2022/03/20/how-i-read-files-in-python/
HARVARDWaylon Walker | Sciencx Sunday March 20, 2022 » How I read Files in Python., viewed ,<https://www.scien.cx/2022/03/20/how-i-read-files-in-python/>
VANCOUVERWaylon Walker | Sciencx - » How I read Files in Python. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/03/20/how-i-read-files-in-python/
CHICAGO" » How I read Files in Python." Waylon Walker | Sciencx - Accessed . https://www.scien.cx/2022/03/20/how-i-read-files-in-python/
IEEE" » How I read Files in Python." Waylon Walker | Sciencx [Online]. Available: https://www.scien.cx/2022/03/20/how-i-read-files-in-python/. [Accessed: ]
rf:citation » How I read Files in Python | Waylon Walker | Sciencx | https://www.scien.cx/2022/03/20/how-i-read-files-in-python/ |
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.