Python File Handling

Read Files Using Python

Example: How to read file


split() using file handling

For loop using file handling

readlines() using file handling

Create File Using Python

create a empty file

Write Files

  1. “a”: It is used to append the content at the end of the file without overwriting the existing content.
  2. “w”: It is used overwrite the existing file and if the file is not created, it will create the file.
  3. write() method is used to append and write to the file.

Delete File Using Python:

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

Recommended from Medium

.format() in Python

Women Soldiers Organization — Week 2/January 5, 2022

Blacklusion October Update

What is a String?

7 Low-Cost, High-Impact Resources to Make the Most of your L&D Budget: IT & Software Edition

Why you should probably leave your current Project

Key Kubernetes Concepts

Facade + PHP 8 🐘 (Design Patterns)

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
Shivansh Sharma

Shivansh Sharma

More from Medium

Upload to Google Drive from CLI | Python3 | Drive API v3

Top 5 Best Python Frameworks

Quick overview of random module in Python

Efficient summation in Python