python
叫我福建
所有的游戏,或者其它,叫我福建就是我叫福建
展开
-
PyQt5 点击后窗口闪现,单击方法绑定后没有反应
问题描述:PyQt5 点击后窗口闪现演示效果:问题解决: def openLayout1(self): # layout1 是不单独运行的窗口 import layout1 self.layoutOne = layout1.Layout1() self.layoutOne.show()解决效果:问题描述:单击方法绑定后没有反应问题解决:方法里面传入 self...原创 2022-04-29 18:32:34 · 346 阅读 · 0 评论 -
PyQt5点击后弹窗新窗口
问题描述:想使用PyQt5 点击后弹出一个新窗口思路:0: 首先得绘制一个窗口1: 一个点击按钮 【 初始化 —> 布局 —> 触发新窗口 】2: 引入另外一个文件的窗口展示 【 这个窗口也可以单独运行 】图片演示:代码:这个方法,指向新的文件 layout1def layoutFn(self): """ 想要有新的窗口, 引用其它已经写好的类 """ import layout1 # 这个是可以单独运行的窗口 self.one =原创 2022-04-29 15:28:06 · 13925 阅读 · 1 评论 -
python + pyqt5 自制exe 随机换壁纸
问题描述:选择自己图片目录,随机更换壁纸效果演示问题解决:直接上代码:# -*- coding: utf-8 -*-# Form implementation generated from reading ui file 'd:\python code\05changePaperWindow.ui'## Created by: PyQt5 UI code generator 5.15.4## WARNING: Any manual changes made to this file原创 2022-03-02 18:45:10 · 625 阅读 · 0 评论 -
Button = QMessageBox.NoButton): argument 1 has unexpected type ‘Ui_changePaperWindow‘, QMessageBox报错
问题描述:问题解决:把 self 修改成 None (大写开头)原因: 因为只有一个主窗口,所以报信息的时候,会直接崩溃原创 2022-03-02 18:33:58 · 633 阅读 · 0 评论 -
ValueError: substring not found, find 方法怎么会把其它内容添加进去
问题描述:当我用 index 方法的时候,出现了 ValueError: substring not found当我用 find 方法的时候,集合把其它内容添加进去了问题解决: 【 使用 find 方法,并进行判断 】if (filePath.lower().find('jpg') > 1 or filePath.lower().find('png') > 1 ):原因:python index 方法里面如果没有匹配到内容就会出现 ValueError: substring n原创 2022-03-02 17:59:44 · 9865 阅读 · 0 评论 -
python+ pyqt5 实现最简单的计算器
问题描述:用python + pyqt5 实现最简单的计算器【 1: 只能进行 2 个数字的运算;2: 除法的第二位数不能是0 】运行效果:问题解决:全部代码如下: 【 只需要进行打包即可, pyinstaller -F ./calculator.py 】import sysimport refrom PyQt5 import QtCore, QtGui, QtWidgetsfrom PyQt5.QtWidgets import QMainWindowclass Calculator原创 2022-03-02 15:54:31 · 902 阅读 · 0 评论 -
函数名() takes 2 positional arguments but 3 were given, 函数名() takes 3 positional arguments but 4
问题描述:如图问题解决:第一个参数添加 self 即可原创 2022-03-01 18:18:19 · 7348 阅读 · 2 评论 -
python + pyqt5 点击按钮修改显示的内容
问题描述:pyqt5 点击按钮修改显示的内容效果演示:问题解决:self.showEdit.setText(senderText) # 按钮改变显示的内容完整代码import sysfrom PyQt5 import QtCore, QtGui, QtWidgetsfrom PyQt5.QtWidgets import QMainWindowclass Calculator_Window(QMainWindow): def setupUi(self, CalculatorWi原创 2022-03-01 15:12:24 · 2920 阅读 · 0 评论 -
python 写 exe 窗口练习记录
窗口 1. 【 finished】1: 可自由缩放2: 有一个按钮进行交换【 比如点击,弹窗弹出消息 】窗口 2:1: 来一个计算器:窗口 3:1: 选择自己电脑上的文件夹2: 并打印出里面的文件;3: 图片选择4: 随机从里面设置壁纸...原创 2022-02-27 17:10:17 · 429 阅读 · 0 评论 -
python + win32api,win32gui,win32con 写 exe 窗口的时候,怎么创建按钮呢?
问题描述:自己用 python + win32api 想写 exe 脚本文件,但是按钮都不会创建python + win32api,win32gui,win32con 写 exe 窗口的时候,怎么创建按钮呢?网上抄来的代码,如果用 tkinter 的话,不是用不到 win32api, win32gui, win32con 了吗?小白上来请教各位大佬import win32guiimport win32apifrom win32con import *def WndProc(hwnd, msg,原创 2022-02-24 18:07:11 · 1216 阅读 · 0 评论 -
python 写一个最简单入门的换壁纸的无界面的exe程序文件
问题描述:想用 python 写一个最简单的 exe 程序文件演示效果:问题解决:直接上代码import platformimport win32api, win32gui, win32conimport osdef changeWallpaper(pic): system_version = platform.platform() print(system_version) system = system_version.split('-')[0] t原创 2022-02-23 11:11:54 · 989 阅读 · 0 评论 -
python3.7 数据转字典类型报错
问题描述:1: 我把 UTF-8 编码的数据传到 pipelines:这个位置各种修改,报各种错误把json_content = json.dumps(dict(item), ensure_ascii=False)改成json_content = json.dumps(dict(item), ensure_ascii=False)json_content = json.dumps(dict(str(item)), ensure_ascii=False)json_content = js原创 2021-08-19 17:19:38 · 321 阅读 · 0 评论 -
Scrapy 改变 写入 csv 的顺序(初始是 Alphabet 排序的)
问题描述:Scrapy 导出的 CSV 是按字母排序的但是我想按照我自己想要的顺序进行排序问题解决:在 settings 里面,添加这一行:FEED_EXPORT_FIELDS = [“name”, “title”, “info”]写入结果如下:原创 2021-08-19 15:16:37 · 340 阅读 · 0 评论 -
Scrapy 的保存目录
问题描述:我 main.py 里面写了如下命令但是我不小在 cmd 里面运行了scrapy crawl projectName -o teacher.json然后就出现了保存到了 scrapy01.json 里面,并没有保存到 cmd 命令里面输入的 teacher.json 里面...原创 2021-08-19 14:56:23 · 180 阅读 · 0 评论 -
Python3.7 Scrapy ModuleNotFoundError: No module named ‘scrapys‘
问题描述:使用 scrapy 引用的时候遇到问题这个引用竟然报错,但是运行没有问题下面的这种写法,报错,但是运行会报错ModuleNotFoundError: No module named ‘scrapys’问题解决:暂时没有解决原创 2021-08-19 14:47:25 · 89 阅读 · 0 评论 -
python3.7 Scrapy open 方法出现 TypeError: write() argument must be str, not bytes
问题描述:python3.7 open 方法 出现TypeError: write() argument must be str, not bytes问题解决:open 用 wb 方法打开原创 2021-08-16 18:20:38 · 167 阅读 · 0 评论 -
python3.7 TypeError: ‘builtin_function_or_method‘ object is not subscriptable
问题描述:安装 Scrapy 调试工具的时候,出现下面的错误D:\pyFile\scrapy01>scrapy shell http://lab.scrapyd.cnTraceback (most recent call last):File “d:\python37-32\lib\runpy.py”, line 193, in _run_module_as_main“main”, mod_spec)File “d:\python37-32\lib\runpy.py”, line 85,原创 2021-08-15 17:58:13 · 607 阅读 · 0 评论 -
python3.7 《我们仨》摘抄写入 9 个txt
问题描述:看到一本好书《我们仨》,想把它分段放到 txt 内容里面,这样就可以让金山打字通,定义进去,每天打字看书。直接上代码(本来是想用 XPath 来分段的,没这么去操作)# -*- coding: UTF-8 -*-import osdef my_begin(path): for i in range(1, 10): path_to_create = path + '\\《我们仨》' + str(i) + '.txt' try:原创 2021-08-10 16:04:11 · 89 阅读 · 0 评论 -
python3.7移动整理图片,Numpy 配合 Cv2 读取中文图片路径
问题描述:1: 想用 python3.7 把一个文件夹下面的所有图片移动并整理到另外一个文件夹里面;2: 只读取图片的长宽,不对图片进行操作(用 PIL 对中文路径行不通)问题解决:# -*- coding: UTF-8 -*-import osimport shutilfrom os import listdirfrom os.path import joinimport numpy as npfrom PIL import Image # 图片处理工具import cv2'原创 2021-08-08 18:34:21 · 394 阅读 · 0 评论 -
python3.7: PermissionError: [WinError 32] The process cannot access the file because it is......
问题描述:python3.7 , 使用 PIL 里面的库 Image 只想获取图片的长和宽报如下错误D:\Python37-32\python.exe D:/pyFile/python_script/img_read.pyTraceback (most recent call last):File “D:\Python37-32\lib\shutil.py”, line 557, in moveos.rename(src, real_dst)PermissionError: [WinErro原创 2021-08-07 21:01:27 · 1507 阅读 · 0 评论 -
python3.7scrapy ‘builtin_function_or_method‘ object is not subscriptable
问题描述:python3.7scrapy ‘builtin_function_or_method’ object is not subscriptable问题解决:splilt 是方法 , 所以要 ()原创 2021-08-01 20:51:24 · 130 阅读 · 0 评论 -
python3.7 scrapy 报错 KeyError: ‘Spider not found: baidu‘
它没有找到 名叫 baidu 的爬虫,所以我根据提示一步一步让它跑起来了先安装了 scrapy再创建了 scrapy01 项目scrapy startproject scrapy01然后我根据提示,到了 scrapy01 这个页面, scrapy genspider example example.com再修改了 example.py:就有了下面的运行日志,不过并没有 “百度知道” 这些字样… …于是,就把 settings.py 里面的ROBOTSTXT_OBEY = True改成了原创 2021-08-01 20:19:14 · 2650 阅读 · 0 评论 -
python3.7 安装 scrapy, pip 升级
安装 pip :python -m ensurepip然后安装 scrapypip install Scrapy输入scrapy 查看有没有安装成功下面是我自己的安装日志<!-- D:\pyFile>pip install pytesseractCollecting pytesseract Downloading pytesseract-0.3.8.tar.gz (14 kB) ERROR: Command errored out with exit status 1原创 2021-08-01 14:31:33 · 675 阅读 · 0 评论 -
python3.7 Selenium 使用cookie 登录
利用已经有的 Cookie 来登录自己已经登录过的网址,不知道还有没有其它的什么问题,请大佬指教def main(): driver = webdriver.Chrome(executable_path="D:\Python_module\chromdriver\chromedriver.exe") driver.maximize_window() driver.get("https://www.pianku.li/") time.sleep(2) my_cooki原创 2021-08-01 13:15:56 · 264 阅读 · 0 评论 -
ValueError: Wrong number of lut entries
问题描述:使用 python3.7 学习 pytesseract 验证码识别的时候报错ValueError: Wrong number of lut entriesim=Image.open("Test.jpg") width=im.size[0] Lim=im.convert("L") threshold = 250 table = [] for i in range(width): if i < threshold: table.append(0)原创 2021-07-31 18:18:57 · 859 阅读 · 0 评论 -
python3.7 Selenium.common.keys 的应用
python3.7 自动登录试试效果# -*- coding=utf-8 -*-from selenium import webdriverfrom selenium.webdriver.common.keys import Keysimport timedef main(): driver = webdriver.Chrome(executable_path="D:\Python_module\chromdriver\chromedriver.exe") driver.ma原创 2021-07-30 18:19:24 · 253 阅读 · 0 评论 -
python3.7,Selenium + webdriver.Chrome 获取腾讯求职信息四
代码:# -*- coding=utf-8 -*-import osimport threadingimport timeimport unittestimport xlwtimport xlrdfrom xlutils.copy import copyfrom selenium import webdriverfrom queue import Queueimport warningswarnings.simplefilter("ignore", ResourceWarning)原创 2021-07-30 14:23:23 · 126 阅读 · 0 评论 -
python3.7,Selenium + webdriver.Chrome 获取腾讯求职信息三
python3.7,Selenium + webdriver.Chrome 获取腾讯求职信息二从控制台已经看到,需要取的数据已经拿到了,后面只需要把取的数据,写入 excel 即可我自己把它封装成一个字典 job_resume, 直接上代码。# -*- coding=utf-8 -*-import osimport xlrd # excel 读取包import xlwt # excel 写入包from xlutils.copy import copy # 操作 excel原创 2021-07-29 22:51:47 · 164 阅读 · 0 评论 -
python3.7,Selenium + webdriver.Chrome 获取腾讯求职信息二
经过一天的调试,终于不再出现线程的问题了大概思路是这样的: 测试单元启动后,添加一个 8 秒的执行时长,从而有足够的时间腾出来打开窗口,关闭窗口,拿到自己想要的数据,这里有一个新的问题就是: 爬取的时间并不是非常契合 (腾讯出求职的信息更新真的相当快哇)# -*- coding=utf-8 -*-import threadingimport timeimport unittestfrom selenium import webdriverfrom queue import Queueimpo原创 2021-07-29 15:42:00 · 143 阅读 · 0 评论 -
python3.7 ,cannot join thread before it is started, 待解决
问题描述:2021年7月28日17:34:5添加了一个阻塞线程之后,以回到了原点:代码以如下:# -*- coding=utf-8 -*-import threadingimport timeimport unittestfrom selenium import webdriver''' 腾讯职位的前 10 位数据, 并写入 excel, 每页有 10 条信息 https://careers.tencent.com/search.html?query=co_1&原创 2021-07-28 17:37:41 · 2602 阅读 · 11 评论 -
python3.7, selenium, driver.Chrome() 测试单元斗鱼简单数据
学习python爬虫,看到爬取斗鱼的房间名,观众数(python3.7 2021年7月28日15:53:20)# -*- coding=utf-8 -*-import unittestfrom selenium import webdriverfrom bs4 import BeautifulSoup as bsclass Tencent(unittest.TestCase): def setUp(self): # 初始化方法 self.driver = web原创 2021-07-28 15:54:19 · 83 阅读 · 0 评论 -
python3.7,Selenium + webdriver.Chrome 获取腾讯求职信息一
问题描述: 想获取腾讯求职信息,但是它现在是用 VUE.JS 渲染的,之前用的 urllib.request 暂时失去了作用,用起了 Selenium + webdriver, Chrome, 上代码, 这是刚刚反复测试的雏形:import timefrom selenium import webdriverfrom selenium .webdriver.common.by import Bydriver = webdriver.Chrome(executable_path="D:\Python原创 2021-07-27 23:52:35 · 115 阅读 · 0 评论 -
使用Phantom.js时报错
问题描述: 在使用 Phantom.js 的时候报错,报错信息如下:D:\Python37-32\python.exe D:/pyFile/10Selenium.pyD:\Python37-32\lib\site-packages\selenium\webdriver\phantomjs\webdriver.py:49: UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versio原创 2021-07-27 20:39:02 · 865 阅读 · 0 评论 -
python3.7 多线程遇到的一个问题,求解决
问题描述: python3.7 学习多线程的时候,一个问题,打印出来的结果为什么是这样的?# -*- coding=utf-8 -*-import threadingfrom queue import Queuefrom lxml import etreeimport requestsimport jsonclass ThreadCrawl(threading.Thread): def __init__(self, thread_name, page_queue, data_qu原创 2021-07-24 20:34:30 · 141 阅读 · 0 评论 -
python3.7 写了一个多线程,啥反应都没有,也不报错,该怎么Debug哪里出现问题呢?
问题描述: python 3.7 跟着写了一段代码,运行后,什么错误都没有显示,也没有报错,求大神帮忙看一下# -*- coding=utf-8 -*-import threadingfrom queue import Queuefrom lxml import etreeimport requestsimport jsonclass ThreadCrawl(threading.Thread): def __init__(self, thread_name, page_queue,原创 2021-07-22 22:00:37 · 916 阅读 · 0 评论 -
python3.7 糗事第一页写入xls
问题描述: 2021年7月21日16:5:57 试着爬取了糗事第一页的 (1: 标题;2: 笑的人数; 3 : 评论人数; 4: 作者)# -*- coding=utf-8 -*-import urllib.requestfrom lxml import etreeimport jsonimport xlwtclass EmbarrassmentEncyclopedia(object): def __init__(self, url): self.url = url原创 2021-07-21 16:09:42 · 44 阅读 · 0 评论 -
python 3.7 json.loads怎么是 list 类型,该怎么处理
问题描述: 想把一个 list 数据,转换成 json 数据,但是通过 json.dumps 处理后,再 json.loads 处理出来是 list 类型(看别人打印出来都是 Dict 字典类型),想知道为什么。问题解决: 待解决原创 2021-07-21 15:13:27 · 1541 阅读 · 4 评论 -
python3.7 爬取数据写入xls(s),jsonpath, xlwt 设置字体,加粗,行高,行宽,合并单元格,居中设置
问题描述: 2021年7月18日23:26:38, 爬取 https://www.lagou.com/lbs/getAllCitySearchLabels.json 的JSON 数据,并写入 xls 文件,稍微设置一点样式。# -*- coding=utf-8 -*-import jsonimport urllib.requestimport jsonpathimport xlwtclass GetCity(object): def __init__(self, url):原创 2021-07-18 23:28:13 · 218 阅读 · 0 评论 -
UnicodeEncodeError: ‘charmap‘ codec can‘t encode character ‘\u7b2c‘ in position 11: character maps
问题描述: JSON 乱码问题, 如图UnicodeEncodeError: ‘charmap’ codec can’t encode character ‘\u7b2c’ in position 11: character maps问题解决:搭配上 open 里面的 encoding=‘utf-8’, mode=‘w’ 使用原创 2021-07-18 16:54:47 · 586 阅读 · 0 评论 -
python3.7, ‘charmap‘ codec can‘t encode characters in position 12-18: \r\n无效的问题
问题描述:1: ‘charmap’ codec can’t encode characters in position 12-18:问题2: with 方法写入 txt 换行 \r\n \n 无效# -*- coding=utf-8 -*-import urllib.requestimport reclass Funny(): def __init__(self): self.working = True # 一直采集开关 # 1: 下载页面原创 2021-07-14 23:14:19 · 1828 阅读 · 0 评论