Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用python搜索目录中的html文件_Python_Html_Search_Path_Directory - Fatal编程技术网

使用python搜索目录中的html文件

使用python搜索目录中的html文件,python,html,search,path,directory,Python,Html,Search,Path,Directory,我有一个html解析器函数,它需要每个文件的绝对路径 如何搜索目录并仅查找以.html结尾的文件,然后返回每个文件的绝对路径 您考虑过使用python os模块吗?它有listdir(path)命令 使用它可以获取目录中的所有文件名,过滤掉非html文件,然后在目录路径前面加上前缀以获取绝对路径。 到目前为止,你们有什么? os.listdir(path) Return a list containing the names of the entries in the directory giv

我有一个html解析器函数,它需要每个文件的绝对路径


如何搜索目录并仅查找以.html结尾的文件,然后返回每个文件的绝对路径

您考虑过使用python os模块吗?它有listdir(path)命令

使用它可以获取目录中的所有文件名,过滤掉非html文件,然后在目录路径前面加上前缀以获取绝对路径。

到目前为止,你们有什么?
os.listdir(path)
Return a list containing the names of the entries in the directory given by path. The list is in arbitrary order. It does not include the special entries '.' and '..' even if they are present in the directory.

Availability: Unix, Windows.