用了递归
Topic source相对路径:print(os.path.split(f)[1])
items.py middlewares.py pipelines.py settings.py groupMail.py LoveEmail.py rk.py test.py WeatherSpider.py wrodCloud.py init.py init.py
- 1
相对路径:print(os.path.split(f)[1])
items.py middlewares.py pipelines.py settings.py groupMail.py LoveEmail.py rk.py test.py WeatherSpider.py wrodCloud.py init.py init.py
KJT11
def findFile(str,path): for x in os.listdir(path): f = os.path.join(path,x) if os.path.isfile(f) and os.path.splitext(f)[1]== str: print(f) elif os.path.isdir(f): findFile(str,f)
if name == 'main': findFile('.py','D:\Python\pythonProject\weather\weather')
D:\Python\pythonProject\weather\weather\items.py D:\Python\pythonProject\weather\weather\middlewares.py D:\Python\pythonProject\weather\weather\pipelines.py D:\Python\pythonProject\weather\weather\settings.py D:\Python\pythonProject\weather\weather\spiders\groupMail.py D:\Python\pythonProject\weather\weather\spiders\LoveEmail.py D:\Python\pythonProject\weather\weather\spiders\rk.py D:\Python\pythonProject\weather\weather\spiders\test.py D:\Python\pythonProject\weather\weather\spiders\WeatherSpider.py D:\Python\pythonProject\weather\weather\spiders\wrodCloud.py D:\Python\pythonProject\weather\weather\spiders__init.py D:\Python\pythonProject\weather\weather\init__.py