Read and Write File with Python

Photo by Beatriz Pérez Moya on Unsplash
This is first line content.
This is second line content.
This is third line content.
file = open('test.txt', 'r')
print(file.read())
file.close()
This is first line content.
This is second line content.
This is third line content.
f = open('test2.txt', 'w')
f.write('This is line content.')
f.close()

--

--

--

Software Engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Microservices with Spring Boot, Docker and Kubernetes Part 2

Serverless Stack Experiences

MySql Installation

The Advantages of the IAP Protocol

ASP.NET Core default project structure explained (part 2)

Why did we start developing Workforces.AI?

Get started with Git: An intro

How I made my own serverless web application in 30 minutes with MongoDB and Surge

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adi Ramadhan

Adi Ramadhan

Software Engineer

More from Medium

Python Pandas Library for Beginners

Python for engineering offices

Python comprehensive intro for beginners with Flask Framework

Python comprehensive intro for beginer with flask framework

How to Create a Data Frame from the Spotify API