目录
#遍历磁盘
import os#导入的模块
from os import path#导入的模块
import sys#导入的模块
def osPath(url):
files=os.listdir(url)#此时files是一个容器
for f in files:#遍历容器
real_path=path.join(url,f)#拼接路径
if path.isfile(real_path):#判断是否是文件
print(path.abspath(real_path))#打印文件的绝对路径
elif path.isdir(real_path):#判断是否是文件夹
#此时是一个文件夹
#需要使用递归继续进行查找
osPath(real_path)#继续调用函数完成递归
else:
print("其他情况")
pass
osPath("D:\\")