使用python搜索目录中的html文件
我有一个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结尾的文件,然后返回每个文件的绝对路径 您考虑过使用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.