pyqt5加载网路图片,不本地下载。
依赖组件:
requests
class webImg: pass if __name__ == '__main__': import sys from PyQt5.QtWidgets import QApplication from PyQt5.QtWidgets import (QWidget, QLabel, QVBoxLayout) from PyQt5.QtGui import QPixmap app = QApplication(sys.argv) import requests url='http://www.test.com/uploads/1.jpg' req = requests.get(url) print(type(req.content)) print(dir(req)) photo = QPixmap() #photo.loadFromData(req.content, "JPG") photo.loadFromData(req.content) label= QLabel() label.setPixmap(photo) widget = QWidget() layout =QVBoxLayout() widget.setLayout(layout) layout.addWidget(label) widget.show() ##################################################### sys.exit(app.exec_())