how to run python file handling program in online editor?

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

1 Answer

0 votes
answered Aug 6 by (300 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

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.
...