Python 定时自动发布微博

注:weibo这个第三方库目前只支持python2.7 3.3 3.4 三个版本 API_KEY 需要再微博api接口那里申请,审核没通过的应用会显示“未通过审核应用” 下面的代码是在python2.7的版本上编写的 # encoding: utf-8 from weibo import Client import schedule,time # API_KEY = ” # API_SECRET = ” # REDIRECT_URI = ‘http://www.henhaoji.net’ # client = Client(API_KEY, API_SECRET, REDIRECT_URI, username=”, password=”) # client.post(‘statuses/share’,status=u’你好微博’ + ‘http://www.henhaoji.net…

Read More

Pyqt5 下载B站视频小软件

import os,re,time,datetime,sys,random,math,webbrowser,menub,threading,json from PyQt5.QtWidgets import * from PyQt5.QtGui import * from PyQt5 import QtWidgets,QtGui,QtCore from PyQt5.QtCore import * from Ui_video import Ui_MainWindow from functools import partial import requests from bs4 import BeautifulSoup from you_get import common as you_get #导入数据库 from PyQt5 import QtSql from PyQt5.QtSql impo…

Read More

QObject::setParent: Cannot set parent, new parent is in a different thread Pyqt5多线程操作出现的错误解决办法

该应用程序试图从不同的线程更新窗口进度条的值(QThreadPool())。当它试图更新进度条时,python给出如下警告: QObject::setParent: Cannot set parent, new parent is in a different thread 这在一定程度上不会影响应用程序,但过了一会儿,应用程序崩溃,出现以下错误消息。 有问题的程序代码 import sys from PyQt5.QtCore import * from PyQt5 import QtCore, QtGui, QtWidgets import thread_for_audio_record import time class FW(object): def __init__(self): self.threadpool = QThreadPool() def f_w(self, windo…

Read More

Python多线程

import time, threading def threadFunction(): while True: print(11111) time.sleep() # 用于命名,可以通过threading.current_thread().name获得 t = threading.Thread(target=threadFunction, name=’funciton’) # 如果线程有参数 t = threading.Thread(target=threadFunction, args=(), name=’funciton’) t.start()   多线程的好处就是不同等到某个函数执行完再去执行别的函数

Python+pyqt5+designer 实现信息录入系统

主程序代码编写 import os,time,datetime,sys,random,math from PyQt5.QtWidgets import * from PyQt5.QtGui import * from PyQt5 import QtWidgets,QtGui from PyQt5.QtCore import * from Ui_info5 import Ui_MainWindow from functools import partial #导入数据库 from PyQt5 import QtSql from PyQt5.QtSql import QSqlQuery class Mywindow(Ui_MainWindow,QMainWindow): def __init__(self): super().__init__() self.setupUi(self) self…

Read More

windows64 位系统下如何使用pyinstaller打包32位的exe–Python知识点

说明:原来安装的python为64位,故安装的pyinstaller和打包后的exe都为64位。而64位的exe文件在32位的win7操作系统下是无法执行的,显示不兼容。网上查询发现,简单(可能不方便)的方法是采用32位的python重新打包。这里,我使用的是conda构建32位python环境,然后再次打包。 注:一开始安装python3.7的版本,打包出现错误 改成python3.6一切正常! 构建32位python环境 进入命令提示符窗口 set CONDA_FORCE_32BIT=1 //切换到32位 =0则切换到64位 conda create –name python36 python=3.6 //创建一个python3.6的环境,命名为python36 conda info –envs //查看是否添加成功 activate python36 //切换到python3.6…

Read More

Pyqt5 +designer实现打字练习软件

主程序文件编写 import os,time,datetime,sys,random from PyQt5.QtWidgets import * from PyQt5.QtGui import * from PyQt5 import QtWidgets,QtGui from PyQt5.QtCore import * from Ui_typing import Ui_MainWindow class Mywindow(Ui_MainWindow,QMainWindow): def __init__(self): super().__init__() self.setupUi(self) #默认句子 with open(“text.txt”, “r”, encoding=”utf-8″) as f: self.text_list = f.readlines() self.text_list …

Read More

PyQT5 图片查看器

一款简易的图片查看器。由官方PyQt4 demo升级为PyQt5版本,原本只有缩放功能,现另加入打印和拖放功能。 #!/usr/bin/env python from PyQt5 import QtCore, QtGui,QtWidgets from PyQt5.QtPrintSupport import QPrinter, QPrintDialog,QPrintPreviewDialog class ImageViewer(QtWidgets.QMainWindow): def __init__(self): super(ImageViewer, self).__init__() self.imageLabel = QtWidgets.QLabel() self.imageLabel.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignVCe…

Read More

如何将PyQt(pyqt-tools)中的Qt Designer改为中文界面(汉化)

说明: 首先直接用pip安装的PyQt-tools的Designer是不带翻译文件的,因此我们要把Qt creator中Designer的翻译文件拷贝到Pyqt的Designer目录中。   步骤1 打开Qt creator的translations文件夹。 笔者的路径:F:\Qt\Qt5.11.1\Tools\QtCreator\share\qtcreator\translations 步骤2 把其中一个文件拷贝,designer_zh_CN.qm是简体中文,designer_zh_TW.qm是繁体中文,这里我们拷贝简体中文的翻译文件。 Ps:不想下载Qt但是又想要designer_zh_CN.qm这个翻译文件的,笔者提供网盘下载地址,https://pan.baidu.com/s/1jzkumqjw-3VQiJxvo4V6Xw 步骤3 将拷贝的翻译文件复制到 PyQt5 的t…

Read More

Pyqt5+designer实现图片转文字桌面小软件

主程序 import requests,json,os,time,datetime,sys from aip import AipOcr import webbrowser import sys from PyQt5.QtWidgets import * from PyQt5.QtGui import * from PyQt5 import QtWidgets,QtGui from PyQt5.QtCore import * import Ui_image4 from functools import partial import requests from bs4 import BeautifulSoup class fileDialogdemo(QWidget): def __init__(self,parent=None): super(fileDialogdemo, self)._…

Read More