EasyEnv
Python
BeginnerLesson 9 of 1930 min · hands-on

Files and IO

Part of the Python course

A program that only prints to the terminal forgets everything the moment it finishes. The next step, and the one that makes Python suddenly feel useful, is teaching it to read from and write to files on disk. In this lesson you will open a file, write some lines into it, read them back, and learn the small handful of patterns that cover almost every file job you will ever do.

There is no main.py in your lesson folder yet. Create it with this program: press Play on the block and the file is made for you. Pressing Play again does not make a second copy. ...

Want to learn Python Files and IO in a real environment?

Click below, get a fresh Linux box with Python ready to go, and work through Files and IO hands-on with an AI tutor that knows your code.

Start this lessonFiles and IO

What you'll learn

  • Open with with
  • Reading lines
  • Writing files
  • Pathlib.Path
  • Json read
  • Json write

Read this lesson in your language

All lessons in this course

19 lessons
  1. 1Hello, Python20 min
  2. 2Numbers and Strings25 min
  3. 3Asking the User a Question15 min
  4. 4Control Flow30 min
  5. 5Lists and Tuples30 min
  6. 6Dictionaries and Sets30 min
  7. 7Functions30 min
  8. 8Comprehensions25 min
  9. 9Files and IO30 min
  10. 10Modules and Packages30 min
  11. 11Classes and OOP35 min
  12. 12Inheritance and Composition30 min
  13. 13Exception Handling30 min
  14. 14Iterators and Generators30 min
  15. 15Decorators30 min
  16. 16Context Managers25 min
  17. 17Concurrency: Threads and Async40 min
  18. 18Testing with pytest35 min
  19. 19Packaging and Deployment35 min

Explore other courses

Files and IO - Python (English) | Engineering Courses