Python File Operations
It is very important for any programming language to interact with the File System and be able to do all the read, write, update, append and delete operations on the files and folders.
List of Examples for Python File Operations
Following examples include operations like read, write, append, update, delete on files, folders, etc., programmatically with Python.
Basic Python File Operations
- Python – Read Text File
- Python – Create New File
- Python – Delete or Remove File
- Python – Create a Directory
- Python – Check if Specified Path is File or Directory
- Python – Get the List of all Files in a Directory and its Sub-directories recursively.
Text File Operations
- Python – Write String to Text File
- Python – Find unique words in Text File
- Python – Append Text to File
- Python – Replace a String in Text File
- Python – Replace multiple spaces with single space in a Text File
- Python – Count Number of Words in a Text File
- Python – Count Number of Characters in a Text File
- Python – Count occurrences of a word in Text File
Error Handling
Summary
In this tutorial of Python Examples, we learned about some of the File Operations that we can apply on files, or for transforming them, etc.