0

Opening files in the phone

How do I open the txt file in the phone? Write me a full example (note that I'm not opening from sd)

18th Jun 2017, 2:58 PM
Kreez
Kreez - avatar
20 odpowiedzi
+ 3
Well in that case; If the file is in the same folder as python files than just specify the file extension. e.g open(test.txt) else if it is in some other directory specify the directory path of the file (check the file path using file explorer) e.g open(storage/sdcard0/test.txt)
18th Jun 2017, 3:46 PM
Lord Krishna
Lord Krishna - avatar
+ 1
Assuming you are on Android(lollipop and higher) 1. open default file explorer app. 2. select internal storage option if available any/ else skip this. 3. go to the storage/sdcard0(Android devices without sdcards have a portion of internal storage as partition for sdcard). 4. click on the txt file; if you have an txt editor app it should show as an option to open with.(download text editor app if you don't have one)
18th Jun 2017, 3:28 PM
Lord Krishna
Lord Krishna - avatar
+ 1
use the same method as above e.g open(storage/sdcard0/python.py) should work.
18th Jun 2017, 4:19 PM
Lord Krishna
Lord Krishna - avatar
+ 1
did you create a file with the extension .py and specify correct file name e.g test.py
18th Jun 2017, 4:28 PM
Lord Krishna
Lord Krishna - avatar
+ 1
remove the text.txt and include your python script file name if it is python.py then e.g (storage/sdcard0/python/python.py)
18th Jun 2017, 4:34 PM
Lord Krishna
Lord Krishna - avatar
+ 1
What app are you using ? did you try that this way with quotes?('storage/sdcard0/python/python.py')
18th Jun 2017, 4:42 PM
Lord Krishna
Lord Krishna - avatar
+ 1
Specify the app & the whole method you used; then I can try to help to the best of my abilites, if you need any help.
18th Jun 2017, 4:52 PM
Lord Krishna
Lord Krishna - avatar
0
stop. i want open files in the python like this open('C:...','...')
18th Jun 2017, 3:31 PM
Kreez
Kreez - avatar
0
It's good. I have one more question. How do I run a file (the program .py) in the compiler by calling it in the directory
18th Jun 2017, 4:05 PM
Kreez
Kreez - avatar
0
dont work please help me
18th Jun 2017, 4:19 PM
Kreez
Kreez - avatar
0
this does not work. He writes that there is no directory or a file with that name does not exist
18th Jun 2017, 4:23 PM
Kreez
Kreez - avatar
0
i writed ('storage/sdcard0/Python/text.txt','r')
18th Jun 2017, 4:30 PM
Kreez
Kreez - avatar
0
error : storage is not defined
18th Jun 2017, 4:38 PM
Kreez
Kreez - avatar
0
yeee man
18th Jun 2017, 4:43 PM
Kreez
Kreez - avatar
0
i like you
18th Jun 2017, 4:43 PM
Kreez
Kreez - avatar
0
how friend
18th Jun 2017, 4:44 PM
Kreez
Kreez - avatar
0
why? all working
18th Jun 2017, 4:54 PM
Kreez
Kreez - avatar
0
men, i have a one problem
19th Jun 2017, 10:18 AM
Kreez
Kreez - avatar
0
look i have writed: f=open('storage\sdcard0\Python\text.txt','r') error: Traceback (most recent call last): File "source_file.py", line 1, in <module> f=open('storage\sdcard0\Python\text.txt','r') IOError: [Errno 2] No such file or directory: 'storage\\sdcard0\\Python\text.txt'
19th Jun 2017, 10:19 AM
Kreez
Kreez - avatar
0
my app: Dcoder (from play market)
19th Jun 2017, 10:21 AM
Kreez
Kreez - avatar