【发布时间】:2016-12-19 06:18:15
【问题描述】:
我正在使用 Python 的 zipfile 和 BeautifulSoup 模块对用户上传的 zip 文件进行内容链接检查。
在 zip 文件中,有一个文件“a.html”,其在 zip 文件中的完整路径是“content/product1/component1/a.html”。文件“a.html”有一个指向另一个 HTML 文件的 <a href="../../product2/component2/b.html"> 链接。
我想知道如何将路径“content/product1/component1/a.html”与“../../product2/component2/b.html”结合起来,得到正确的路径,即“content/product2” /component2/b.html”。所以我可以检查这个文件存在的位置。
我尝试了os.path.join("content/product1/component1/a.html","../../product2/component2/b.html),但没有得到“content/product2/component2/b.html”。有人知道怎么做吗?
【问题讨论】: