Movatterモバイル変換


[0]ホーム

URL:


Python 3 "pathlib" Module: Taming The Filesystem

Using Python's pathlib Module

Have you struggled withfile path handling in Python? With thepathlib module, the struggle is now over! You no longer need to scratch your head over code like this:

Python
>>>path.rsplit('\\',maxsplit=1)[0]

And you don’t have to cringe at the verbosity of something like this:

Python
>>>os.path.isfile(os.path.join(os.path.expanduser('~'),'realpython.txt'))

In this video course, you’ll learn how to:

  • Work withfile paths in Python
  • Read andwrite files in new ways
  • Manipulate paths and the underlying file system
  • List files anditerate over them

Using thepathlib module, the two examples above can be rewritten using elegant, readable, and Pythonic code:

Python
>>>path.parent>>>(pathlib.Path.home()/'realpython.txt').is_file()

That’s what you’ll master in this video course!

What’s Included:

Downloadable Resources:

Related Learning Paths:

Start Now

Understanding Python File Paths

2 Lessons 3m

  1. 1. Using Python's pathlib Module (Overview)01:31
  2. 2. Understanding Python File Paths02:10

Working With Paths

3 Lessons 9m

  1. 1. Working With Paths03:49
  2. 2. Reading and Writing Files03:01
  3. 3. Moving and Deleting Files02:23

Diving Deeper Into Paths

4 Lessons 12m

  1. 1. Picking Out Components of a Path01:37
  2. 2. Exploring the Finer Details of Path05:19
  3. 3. Trying Out pathlib in Action05:02
  4. 4. Using Python's pathlib Module (Summary)00:54
Start Now

AboutDarren Jones

With 20 years as a teacher of music technology, Darren is keen to bring his skills to the Python table.

» More about Darren

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

Related Courses:

← Browse All Courses


[8]ページ先頭

©2009-2026 Movatter.jp