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, Indonesia

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

Recommended from Medium

Scripting Saturday: AppXManifest.xml

Day 37 — Teamwork

Scrum tips: Differences between epics, stories, themes and features

Quantpedia in March 2022

The Complexity of Stack Overflow

The weird correlation between Rock Climbing and Programming and what they have taught me.

How to become a Web Developer? (Part 2)

Serverless Database Backup Monitoring with Oracle Functions, Oracle Events Service & Oracle…

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, Indonesia

More from Medium

Python comprehensive intro for beginners with Flask Framework

Python comprehensive intro for beginer with flask framework

Create a QUIZ APP using Python!

100 Projects For Beginners Using Python

Python Exercises 1 — Basic