+ 1

Open a File with Pyton on Sololearn

Sorry, I hope someone could help me. How can I use a file with Pyton on Sololearn app? I think I should load it in a memory space in the web or in the app or something similar, but I don't know how. Thanks!

12th Sep 2019, 6:35 AM
Raffaele Bisogno
Raffaele Bisogno - avatar
4 Réponses
+ 2
Sousou thank you but this is what I know. I don't know where the file should be loaded to be opened by the code.
14th Sep 2019, 4:05 PM
Raffaele Bisogno
Raffaele Bisogno - avatar
0
If you want to open file using python: https://code.sololearn.com/cGbrpvGbk8Pn/?ref=app you can see this; https://www.w3schools.com/python/python_file_handling.asp I hope that my answer helps you :)
12th Sep 2019, 9:51 AM
Sousou
Sousou - avatar
0
When you open with "a" mode , the write position will always be at the end of the file (an append). There are other permutations of the mode argument for updating (+), truncating (w) and binary (b) mode but starting with just "a" is your best. If you want to seek through the file to find the place where you should insert the line, use 'r+'. You can also use file access_mode "a+" for Open for reading and writing. The file is created if it does not exist. The stream is positioned at the end of the file . The initial file position for reading is at the beginning of the file, but output is appended to the end of the file. with open("index.txt", "a+") as myfile: myfile.write("New text appended") http://net-informations.com/JUMP_LINK__&&__python__&&__JUMP_LINK/iq/append.htm
10th Jun 2020, 6:12 AM
rahul kumar
rahul kumar - avatar
0
rahul kumar ,ok. But where is "index.txt"? In my phone? In the web? In which folder?
2nd Aug 2020, 9:11 AM
Raffaele Bisogno
Raffaele Bisogno - avatar