课程: Python Essential Libraries
今天就学习课程吧!
今天就开通帐号,24,100 门业界名师课程任您挑!
Walking a file system
- [Instructor] One of the more common scenarios that you will see when working with files and directories involves performing some kind of processing on all of the items within a given directory, including subdirectories, and this can be for a variety of reasons. Perhaps you're searching for a particular file, or a piece of information, or you're performing some kind of batch operation, like converting file formats or renaming items. This process is sometimes called walking a file tree, and the PyFilesystem library makes this process really easy by providing an API specifically for this purpose. So let's go ahead and open up the walking_start file, and let's try a basic example. So here in the example code I have imported the OS file system and I've created a file system object for the current directory. So to iterate over all the files within the directory and all the subdirectory I can use the files function which will…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。