如果没有指定要保存的文件,我创建了这个:
def start_download(self):
self.reply = self.manager.get(QNetworkRequest(QUrl(self.url_edit.text())))
self.reply.downloadProgress.connect(self.download_progress)
self.label.setText(self.url_edit.text())
def download_progress(self, received, total):
print(received, type(received))
我提到的最后一个函数写了收到的字节。所以,下载了。没有我指定的保存路径,它去了哪里?我怎样才能保存它?
答案 0 :(得分:2)
回复是QNetworkReply,是QIODevice的子类。因此,它大致相当于在python中找到的类文件对象。
文件下载后,您应该可以执行以下操作:
data = self.reply.readAll().data()
它将为您提供一个python字节字符串,可以通常的方式保存到磁盘。