Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.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从Mozilla Firefox下载文件?_Python_Html_Firefox_Safari - Fatal编程技术网

Python 如何使用HTML从Mozilla Firefox下载文件?

Python 如何使用HTML从Mozilla Firefox下载文件?,python,html,firefox,safari,Python,Html,Firefox,Safari,我的任务是,如果用户单击下载链接下载文件,该文件应自动下载。我完成了这个任务,并在浏览器chrome和IE中获得了成功的输出。现在我的问题是,我的代码不适用于浏览器mozilla firefox和safari。请帮我解决这个问题 ff = open('sample.html','a') ms = """<h2>PRODUCT SUMMARY</h2> <center><table border = "1"> <tr> <t

我的任务是,如果用户单击下载链接下载文件,该文件应自动下载。我完成了这个任务,并在浏览器chrome和IE中获得了成功的输出。现在我的问题是,我的代码不适用于浏览器mozilla firefox和safari。请帮我解决这个问题

ff = open('sample.html','a')
ms = """<h2>PRODUCT SUMMARY</h2>
<center><table border = "1">
<tr>
    <th>PRODUCT ID</th>
    <th>PRODUCT DOWNLOAD</th>
</tr>"""
ff.write(ms)
for row in __builtin__.product_info:
    ff.write("<tr>")
    ff.write("<td> %s</td>" %str(row[0]).strip())
    ff.write("<td>")
    ff.write("<a href= '%s' download>Download</a>" %str(row[1]).strip()) #(The problem is here..)
    ff.write("</td>")
    ff.write("</tr>")

m = """</center></table>
<br>
</pre>
</body>
</html>"""
ff.write(m)
ff.close()
ff=open('sample.html','a')
ms=“”产品摘要
产品ID
产品下载
"""
ff.写入(毫秒)
对于内置产品信息中的行:
ff.写(“”)
ff.write(“%s”%str(行[0]).strip())
ff.写(“”)
ff.write(“%str(行[1]).strip())#(问题在这里..)
ff.写(“”)
ff.写(“”)
m=”“”

""" ff.写入(m) ff.close()
您可以使用此HTML标记创建下载链接:

<a href="link/to/file" download>Download link</a>

在MAC OS中,如果您想在浏览器safari、chrome和mozilla firefox中使用HTML下载文件,请使用以下代码。所有这些浏览器都会下载所有压缩文件(.zip)



Bartosz,谢谢你的回复。我使用了相同的下载属性,但仍然无法获得输出。这在chrome和IE中都可以使用。但是在firefox和safari中失败了。帮帮我。我希望我可以,但我不知道这是关于ff.write等的东西,为什么不能在firefox或safari上使用,对不起,伙计。
 <a href = "file:///Users/Shared/product_info.zip" download>Click to download</a>