CoolClare
import os.path
while True:
rootdir=input(\'请输入遍历文件夹的绝对路径:(q退出)\')
if rootdir==\'q\':
break
if not(os.path.exists(rootdir)):
print("输入的路径不存在,请重新输入!!")
continue
for parent,dirnames,filenames in os.walk(rootdir):
#三个参数:分别返回1.父目录 2.所有文件夹名字(不含路径) 3.所有文件名字
for dirname in dirnames:
#输出文件夹信息
print( "parent is:" + parent)
print("dirname is" + dirname)
for filename in filenames:
#输出文件信息
print( "parent is:" + parent)
print( "filename is:" + filename)
print("the full name of the file is:" + os.path.join(parent,filename))

分类:

技术点:

相关文章:

  • 2021-11-18
  • 2021-11-18
  • 2022-12-23
  • 2021-12-10
  • 2021-12-10
  • 2021-12-10
猜你喜欢
  • 2021-12-15
  • 2022-12-23
  • 2022-01-30
  • 2022-12-23
  • 2021-09-22
  • 2021-04-27
相关资源
相似解决方案