コンピューターに保存されている HTML ファイルを Web ブラウザーで開きたいのですが、エラーが発生します (以下を参照)。
from urllib import urlopen
from webbrowser import open as webopen
from os import getcwd
from os.path import normpath
私はこのコードを持っています:
def open_html_file():
path = normpath.abspath('New_News.html')
url = 'file://' + path
with open(path, 'w') as f:
f.write(html)
webopen.open(url)
コードを実行すると、次のエラーが発生します。
AttributeError: 'function' object has no attribute 'abspath'