jag*_*ags 4 html windows firefox internet-explorer google-chrome
我正在编写以下程序:
***import os
filepath=r'C:\TestData\openfolder.html'
abc=open(filepath,'w')
abc.writelines('<html><head></head><body>')
abc.writelines('<a href="os.startfile(filepath)">First Link</a>\n')
abc.writelines('</body></html>')***
Run Code Online (Sandbox Code Playgroud)
我想要做的是如果我在浏览器上单击First Link,我应该能够打开路径为"Filepath"的文件夹.os.startfile非常适合打开文件夹,但我不知道如何在某个链接中实现它.谢谢.
尝试在你的html中使用带有file:方案的URI file:///C:/TestData/openfolder.html:
<a href="file:///C:/TestData/openfolder.html">Link to test data</a>
Run Code Online (Sandbox Code Playgroud)
UPD(从评论中提取):每个浏览器都有自己的方式来处理这些网址.至少Windows 7下的Internet Explorer 8会按照jags的要求在Windows资源管理器中打开链接.
最后,对于动态页面,需要Web服务器.如果需要,请查看有关使用python创建简单Web服务的讨论.
| 归档时间: |
|
| 查看次数: |
74272 次 |
| 最近记录: |