课程: Python Essential Libraries
今天就学习课程吧!
今天就开通帐号,24,100 门业界名师课程任您挑!
Solution: PyFilesystem
(upbeat music) - Okay, let's take a look at how I chose to approach this problem and what my solution looks like. And again, I want to emphasize, it's not important that your solution matches mine. So, what's important here is that there's multiple ways of solving a particular problem, and that we learn from different points of view. So, remember that the challenge is that we're trying to calculate a total value of all the bytes of text files within a given folder. So, let me go ahead and open up the challenge solution. All right, so since we're trying to calculate a total value, I start off by having a variable that will hold the total size of all the bytes and initialize that to zero. Then, I use pi file system to create a local file system in my current directory, because that's where the file examples folder is. And, since I need process all the files in the directory, I'm going to use a walker with the info method…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。