12FILES AND FOLDERS

image

Files let you store data in a persistent and sharable manner. It’s all but impossible to do any real work without them. Python comes with many modules and methods for working with files, folders, and directory paths. These let you read and write text files; preserve complex data after you exit your program; create, move, and delete folders; and perform other system-level tasks.

In this chapter, we’ll use the built-in operating system (os), path library (pathlib), and shell utilities (shutil) modules to work with files, folders, and directory paths. We’ll then use built-in functions to open, read, write, and close text files, ...

Get Python Tools for Scientists now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.