今天就学习课程吧!
今天就开通帐号,24,600 门业界名师课程任您挑!
Solution: Files
- [Instructor] All right, so for this challenge, we needed to add up all of the byte sizes of the text files in the Deps Directory and we had to ignore any files that were not text files. So in my code, I have to import the OS module and I gave this as a bit of a hint in the instructions was to look at the OS and OS Path modules. So I import OS because I'm going to make use of the code in that module. And then in my code, I have a variable that keeps track of the total byte count so far and that is initialized to zero. Then I have a variable that contains the name of the Deps Directory, and I made it a variable because I'm going to use it several times. So to get a list of the contents of the directory, I can use the listdr function, which is contained within the OS module, which is part of the Python Standard Library. That will give me a list of file names, but those file names don't have the directory path in them.…