尝试写入 html 文件时出现权限错误

Getting Permission Error when trying to write html file

所以我正在尝试创建一个 web 地图,每次我试图将地图对象保存为 HTML 文件时,我都会收到一条错误消息,告诉我“权限被拒绝。 “我在这里做错了什么?

import folium
>>> map = folium.Map(location=[80, -100])
>>> map
<folium.folium.Map object at 0x00B8AF70>
>>> map.save("Map1.html")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\austi\AppData\Local\Programs\Python\Python38-32\lib\site-packages\bran
ca\element.py", line 161, in save
    fid = open(outfile, 'wb')
PermissionError: [Errno 13] Permission denied: 'Map1.html'

我认为这是因为您没有在正确的位置(在您有权这样做的地方)创建 HTML 文件。您最好为 HTML 文件名使用绝对路径(而不是相对路径),例如:

map.save(r"C:\Users\austi\Map1.html")