准备环境 安装 pyqt5终端里输入pip install PyQt5安装完成后创建一个test。py文件import sys from PyQt5.QtWidgets import QApplication,QMainWindow from PyQt5.QtCore import QUrl from PyQt5.QtWebEngineWidgets import QWebEngineView class MainWindow(QMainWindow): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setWindowTitle('浏览器标题') self.showMaximized() self.webview = WebEngineView() self.webview.load(QUrl("https://www.baidu.com")) self.setCentralWidget(self.webview) class WebEngineView(QWebEngineView): windowList = [] def createWindow(self, QWebEnginePage_WebWindowType): new_webview = WebEngineView() new_window = MainWindow() new_window.setCentralWidget(new_webview) self.windowList.append(new_window) return new_webview if __name__ == "__main__": app = QApplication(sys.argv) window = MainWindow() window.show() sys.exit(app.exec_())b 保存完毕直接执行test.py 如果出现报错 那是应为咱们安装的pyqt5版本太新了包里不包含PyQtWebEngine所以需要咱们主动安装一下ModuleNotFoundError: No module named 'PyQt5.QtWebEngineWidgets' 安装 PyQtWebEnginepip install PyQtWebEngine 安装完成就生成了一个浏览器