![]() Print(f.read()) Output ➜ pyt python3 app.py Now, read the content and print it on the console. Now, we will open this file using the following code. We have a file called data.txt, which has the following content written in it. The open() function returns the file object with a read() method for reading the file’s content. To read a file in Python, use the open() and read() functions. The next step is to open and read a file. # app.pyį.writelines()Īfter you run the above code, you will get the file named data.txt with the following content.
0 Comments
Leave a Reply. |