
Basic File I/O in Python
A Python program that never touches a file forgets everything the moment it exits. File I/O is how your code keeps data after the run ends—saving notes,…
Read tutorialReading, writing, locating, and safely managing files, folders, and file-based data in Python.
Tagged articles
18 articles in this tag.

A Python program that never touches a file forgets everything the moment it exits. File I/O is how your code keeps data after the run ends—saving notes,…
Read tutorial
You finished the syntax tutorials. You know what a loop does, you can write a function, and you understand what a dictionary is for. Then you close the…
Read tutorial
You've learned Python's building blocks—input(), functions, dictionaries, files, loops, conditionals—but you haven't yet seen how they lock together into…
Read tutorial
Somewhere on a server, a program is keeping a diary. Every few seconds it writes a line about what just happened: a user logged in, a request completed, a…
Read tutorial
Every spreadsheet person knows the feeling. You export a CSV file, open it, and find blank rows scattered through the data. Names written three different…
Read tutorial
Counting words in Python sounds trivial until you try it on real text. The moment your sentence contains a comma, a capital letter, or an ellipsis, the…
Read tutorial
Your first program is not really about the words "Hello, World!" It is about proving the whole loop works: you write code, the computer runs it, and you…
Read tutorial
You can see the file right there in your folder. You double-check the name. It's spelled correctly. And yet Python raises FileNotFoundError and refuses to…
Read tutorial
You have data. Someone else needs to understand it. The fastest bridge between the two is a plain text report—a file you can email, save, or hand to a…
Read tutorial
CSV files are how the working world hands data to Python. If you've ever exported a spreadsheet, downloaded a report from a website, or pulled data from a…
Read tutorial
Reading about file handling is easy. Writing code that actually reads a file, transforms its data, and writes something new back to disk is where the skill…
Read tutorial
Your script reads a file, does some work, and closes the file on the last line. Then an error shows up halfway through. The close() line never runs. The…
Read tutorial
You have learned Python pieces: input(), lists, functions, if statements, and file handling. Now it's time to stop practicing them one at a time and start…
Read tutorial
You write a file path as a string. Your script works perfectly on your machine. Then you share it with a friend on Windows—or move it to a server running…
Read tutorial
Every script starts with a simple promise: I'll just change this value when I need to. Then the script grows, the value gets buried deeper, and you find…
Read tutorial
You have a folder full of files with names like photo_2021_01.jpg, IMG_0042.jpg, and final_FINAL_v3.txt. You need them cleaned up, numbered, or renamed to…
Read tutorial
The fastest way to make Python feel real is to build something small that collects data, organizes it, saves it to a file, and reads it back. In this…
Read tutorial
JSON is the closest thing programming has to a shared language. When one program needs to send data to another—across the internet, between a server and an…
Read tutorial