python用迭代器方式便利目录下的文件

<span class="kwd">from<span class="pln"> pathlib <span class="kwd">import<span class="pln"> <span class="typ">Path<span class="pln">

pths <span class="pun">=<span class="pln"> <span class="pun">[<span class="pln">pth <span class="kwd">for<span class="pln"> pth <span class="kwd">in<span class="pln"> <span class="typ">Path<span class="pun">.<span class="pln">cwd<span class="pun">().<span class="pln">iterdir<span class="pun">()<span class="pln"><span class="kwd"><span class="pln"><span class="pun"><span class="pln"><span class="pun"><span class="pln"><span class="str"><span class="pun">]<br><br>&#x5982;&#x679C;&#x662F;os.listdir()&#x8FD9;&#x4F1A;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;list&#xFF0C;&#x6587;&#x4EF6;&#x975E;&#x5E38;&#x591A;&#x7684;&#x65F6;&#x5019;&#x53EF;&#x80FD;&#x6BD4;&#x8F83;&#x8017;&#x5185;&#x5B58;</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>

Original: https://www.cnblogs.com/ymy124/p/5843044.html
Author: 网名还没想好
Title: python用迭代器方式便利目录下的文件

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/7839/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

最近整理资源【免费获取】:   👉 程序员最新必读书单  | 👏 互联网各方向面试题下载 | ✌️计算机核心资源汇总