如何在python中提取文件夹名?

2024-09-27 02:23:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我的文件夹名称作为电影标题,在python中提取电影名称作为文件夹后,它将被用作电影标题,通过usnibg omdb API找到电影描述,然后找到电影的速率当我们看到电影速率时,文件夹将被删除


Tags: 文件夹名称api标题电影速率omdbusnibg
1条回答
网友
1楼 · 发布于 2024-09-27 02:23:23
os.walk(top, topdown=Ture, onerror=None, followlinks=False)

module os中的walk()函数可以遍历文件夹中的所有文件

函数返回一个元组(dirpath、dirnames、filenames)

参数:

dirpath:string, the path of directory,

dirnames:list, includes all directories’ name

filenames:list,includes all files’ name.

附言

目录名和文件名不包含路径信息,如果需要完整的路径,请使用os.path.join(目录路径,目录名)

相关问题 更多 >

    热门问题