Discuss / Python / 作业

作业

Topic source

第一题

<pre> with os.scandir('..') as it: for entry in it: print(entry.name.encode('utf-8')) </pre> 第二题 <pre> import os def searchFile(path,filename): with os.scandir(path) as it: for entry in it: if entry.is_file() and filename in entry.name : print(entry.path.encode('utf-8')) elif entry.is_dir(): searchFile(entry.path,filename) searchFile('/Downloads','py') </pre>


  • 1

Reply