Python中如何使用模块打开网页

幸好思念无声,可惜思念无声

                                ——24.6.4 

Python打开前端网页

1.导入webbrowser

webbrowser.open(传入网址),打开网页

import webbrowser
webbrowser.open("Index.html")

2.用flask框架

from wsgiref.simple_server import make_server


def app(env, response):
    # "flask/django application"
    print("正在监听")
    response('200 OK', [("content-type", 'text/html')])  # 定义响应头
    return ['cuteboy']


# 初始化一个服务器
server = make_server('', 5100, app)
server.serve_forever(0.2)

点击网页链接即可打开

作者:L_cl

物联沃分享整理
物联沃-IOTWORD物联网 » Python中如何使用模块打开网页

发表回复