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 File Object
Python Readline Method
Parsing JSON files to dictionary
Python Append To File
Python Write To File
Python Readlines Method
Class csv.DictWriter
Python Read Method
Python File Object
Python File Object
A Python file object is created when a file is opened with the open()
function. You can associate this file object with a variable when you open a file using the with
and as
keywords. For example:
with open('somefile.txt') as file_object:
You can then print the content of the file object, file_object
with print()
.
print(file_object)
You might see something like this on the output terminal:
<_io.TextIOWrapper name='somefile.txt' mode='r' encoding='UTF-8'>
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