OPENING FILES IN PYTHON | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

OPENING FILES IN PYTHON

IS IT POSSIBLE TO OPEN A FILE USING PYTHON ON THE PLAYGROUND THROUGH SOLOLEARN? THANK YOU...

11th Oct 2022, 9:26 PM
xander cage
2 Answers
+ 1
file = open("/usercode/files/books.txt", "r") rl = file.readlines() for r in rl: print(r) file.close() https://www.sololearn.com/compiler-playground/co6jEhLuMsB5
11th Oct 2022, 10:15 PM
SoloProg
SoloProg - avatar
0
I got this answer in same forum check if this is working. You can create empty file : f = open("myfile.txt", "x") And also Create a new file if it does not exist: f = open("myfile.txt", "w")
12th Oct 2022, 5:54 AM
Jimmy Wick
Jimmy Wick - avatar