Python File Handling and Django Config Files

Day 14 of my Python Full Stack journey. ✅ Today's topic: File Handling — making data survive after the program closes. This is where Python stops feeling like exercises and starts feeling like real software. Here's what I typed today: # Writing to a file with open("students.txt", "w") as file: file.write("Punith: 88\n") file.write("Rahul: 92\n") # Reading from a file with open("students.txt", "r") as file: content = file.read() print(content) # Appending to a file with open("students.txt", "a") as file: file.write("Priya: 76\n") Biggest lesson today: Always use 'with open()' instead of just open(). It automatically closes the file even if an error occurs. One line saves you from a lot of headaches. ✅ Why this matters for Django: → Django reads config files on startup → Log files track every request your app receives → Media uploads are files stored on your server Understanding file I/O now makes all of that make sense later. Two weeks done. Still showing up every single day. 💪 #PythonFullStack #Day14 #BuildingInPublic #100DaysOfCode #Bangalore

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories