Files
Learn how to work with files in an automated way! Investigate the properties of text, CSV, and JSON files by reading and writing to them!
StartKey Concepts
Review core concepts you need to learn to master this subject
Python Readline Method
Python File Object
Parsing JSON files to dictionary
Python Append To File
Python Write To File
Python Readlines Method
Class csv.DictWriter
Python Read Method
Python Readline Method
Python Readline Method
To read only one line instead of multiple lines in a Python file, use the method .readline()
on a file object that is returned from the open()
function. Every subsequent .readline()
will extract the next line in the file if it exists.
with open('story.txt') as story_object: print(story_object.readline())
will print only the first line in story.txt
.
What you'll create
Portfolio projects that showcase your new skills
How you'll master it
Stress-test your knowledge with quizzes that help commit syntax to memory