数独博士 注册码,it英才网,mm公寓新人
补充缺失的代码
def print_directory_contents(spath): """ 这个函数接受文件夹的名称作为输入参数, 返回该文件夹中文件的路径, 以及其包含文件夹中文件的路径。 """ # 补充代码
答案
def print_directory_contents(spath): import os for schild in os.listdir(spath): schildpath = os.path.join(spath,schild) if os.path.isdir(schildpath): print_directory_contents(schildpath) else: print schildpath
特别要注意以下几点:
os
模块与操作系统进行交互,同时做到交互方式是可以跨平台的。你可以把代码写成schildpath = spath + '/' + schild
,但是这个在windows系统上会出错。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Python爬虫:Request Payload和Form Data的简单区别说明
浅谈Python中threading join和setDaemon用法及区别说明
Python3-异步进程回调函数(callback())介绍
python继承threading.Thread实现有返回值的子类实例
Python中使用threading.Event协调线程的运行详解
网友评论