from pathlib import Path
def openfile(path:str)->None:
yield path
def cix(path:str):
p=Path(path)
if p.exists():
if p.is_file():
yield from openfile(str(p))
elif p.is_dir():
for item in p.iterdir():
if item.is_file():
yield from openfile(str(item))
elif item.is_dir():
yield from cix(str(item))
for b in cix("d:/wamp"):
原文:https://www.cnblogs.com/dissipate/p/13760974.html