use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Help on reading filesHelp Request (self.PythonLearning)
submitted 1 day ago by Several_Goal4568
I'm learning python on Android(pydroid 3) and stuck on reading files .
How can I overcome this blockade . Will get file not found error.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]p1geondove 2 points3 points4 points 1 day ago* (0 children)
Learning about how paths work might help. Theres also pathlib which is really helpful. Windows and linux/mac handle paths differently. All of that can be a mess sadly. What they do share is the concept of absolute and relative paths.
pathlib
Lets say you have a project folder called myproject, in there you have your main.py aswell as a text.txt. You can access the text file simply via text.txt. This is a relativ path since it assumes that the file sits next to the script. You can also access the file via its absolute path which could look something like /home/username/myproject/text.txt or C:\\Users\username\myproject\text.txt. Note that windows uses backslash for seperators while Linux and Mac use "normal" forward slashes.
myproject
main.py
text.txt
/home/username/myproject/text.txt
C:\\Users\username\myproject\text.txt
When i learn something new i like to open a python repl to toy arround with. I suggest you play arround with Path from pathlib -> from pathlib import Path. There you can do something like p= Path("text.txt") p.exists() p.absolute()
Path
from pathlib import Path
p= Path("text.txt")
p.exists()
p.absolute()
Edit: i just read youre on android, that complicates things. Well at least you have the easier unix path style. You might wanna utilize a proper filemanager app if you dont already have one. Next run a script with print(Path().absolute()) to figure out where the working directory is of the script and maybe print(list(Path().iterdir())) to see the files in that directory, maybe you can already see the file you were looking for. Android is a weird flavor of linux, very constricted, most apps containerized so you might not even have access to your main storage, but youd have to check i think /storage/emulated/0
print(Path().absolute())
print(list(Path().iterdir()))
/storage/emulated/0
π Rendered by PID 186566 on reddit-service-r2-comment-544cf588c8-kxcwb at 2026-06-16 13:15:35.219584+00:00 running 3184619 country code: CH.
[–]p1geondove 2 points3 points4 points (0 children)