Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

how to run python file handling program in online editor?

+5 votes
asked Jul 10, 2019 by anonymous
how to execute the python file handling programs through on line python compiler

1 Answer

+1 vote
answered Aug 6, 2019 by Raghav7425 (320 points)

Create a new file named some_file.txt and enter some text in that file. When you save it, it will ask for Project Name. I entered project name as File, you can name it accordingly.

Then, in main.py file, write the code given below:

f=open("some_file.txt", "r")
file_data=f.read()
f.close()
print(file_data)

Now, click on Run button.

In terminal, it will display the text written in some_file.txt file.

I am unable to attach screenshot. But, if you face any problem, then just ask

commented Feb 17, 2021 by Devika (100 points)
How to add files to python program
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...