随笔分类 - Python
1
编程语言Python知识
摘要:# -*- coding:utf-8 -*- import threading import time class Producer(threading.Thread): # 生产者函数,重写run()方法 def run(self): global count while True: if con
阅读全文
摘要:代码段1: 1 # -*-coding:utf-8 -*- 2 from threading import Thread, BoundedSemaphore 3 from datetime import datetime 4 import time 5 6 # 定义一个函数 7 def showti
阅读全文
摘要:1.首先对于blob类型做一个说明: 对于mysql或者mariadb有4个可选的blob类型: tinyblob:最大存储数据的长度为255字节 blob:最大存储的数据长度为65535字节,也就是65Kb mediumblob:最大存储的数据长度为16777215字节,也就是16Mb longb
阅读全文
摘要:将python的py文件编译成pyc文件的命令如下: python -m py_compile 待编译的py文件 示例: python -m py_compile hello.py python3 -m py_compile hello.py 对于编译后的pyc文件,有一定的限制: 1. 如果你在w
阅读全文
摘要:前面文章提到【python操作mysql和mariadb数据库】是关于python操作数据库的一些说明,那么要使用python来操作数据库,必须要安装对应数据库连接器,类似于数据库驱动程序 本文将说明在linux centos 7.9下面安装mariadb的数据库连接器的关键点: 官方有说明安装连接
阅读全文
摘要:详细参考官方文档:https://pip.pypa.io/en/stable/user_guide/ 环境 Linux Centos 7.9 默认自带python 2.7 安装 yum install python3-pip 升级 pip3 install pip -U 升级完成后,可以查看版本 p
阅读全文
摘要:在python中捕获异常语法为: try: 语句1 语句2 ... except 异常名 as 异常别名: 语句1 语句2 ...else: 语句1 语句2 ...finally: 语句1 ... 例子: def divide(x, y): try: result = x / y except Ze
阅读全文
摘要:目标 从python3.4.6 升级到python 3.9 pip升级到3.9 1. 查看系统中已经安装的python信息 # zypper se python # rpm -qa | grep python # python --version # python3 --version 2.查看pi
阅读全文
摘要:当在python3中使用Ladon库发布webservice的时候,如果定义的方法中包含中文字符(参数说明除外),例如下面代码,到导致在web端http://localhost:port中出现无法查看soap的description 1 class AccountManager(object): 2
阅读全文
摘要:一、什么是二维码 二维码——百度百科:https://baike.baidu.com/item/%E4%BA%8C%E7%BB%B4%E7%A0%81/2385673?fr=aladdin QRCode——百度百科:https://baike.baidu.com/item/QRCode 二、二维码相
阅读全文
摘要:生成xmlrpc的描述,报错,是因为一个代码bug导致,在ladon的安装目录..\Python\Python39\site-packages\ladon\interfaces 下,找到文件xmlrpc.py,打开编辑 在156行的原代码: for type_class, type_info in
阅读全文
摘要:发现比较好用的OCR识别的库: easyocr tesseract 这两个库都有对应的python包装
阅读全文
摘要:今天新安装了ladon的第三方库,在写webservice的客户端解析程序的时候,报了这个错误: exec("self.%s = types.MethodType(placeholder,self)" % method_name) File "<string>", line 1, in <modul
阅读全文
摘要:一般错误的原因是这个库不支持中文的解码(二维码内容包含中文)。 修改如下: 进入zxing.__init__.py代码中,类BarCode下,parse方法中: 找到下面这两行原代码如下: 1 raw = raw[:-1].decode() 2 parsed = parsed[:-1].decode
阅读全文
摘要:python3.9和之前的版本中没有switch case类似的语句,但是下面的IF语句却与之类似,却又不同: A = B = C = D = E = 1 if A == 1: B=2 elif B ==2: C=3 elif C == 3: D=4 else: E=5 print(A,B,C,D,
阅读全文
摘要:在官方网站已经提交相关issue,不过目前看好像还没有修复。具体的bug位置为: http文件夹下的client.py文件,代码位置为:类HTTPMessage下的方法getallmatchingheaders 源代码如下: def getallmatchingheaders(self, name)
阅读全文
摘要:因为Canvas没有直接将画布内容保存为图片的方法,所以很多时候是通过获得Canvas画布的坐标,然后通过截图的方式来将画布内容保存为本地图片。 如何取得Canvas画布的坐标呢,比较简单实用的方式如下: x0 = cv.winfo_rootx() # 画布的左上角的X轴坐标 y0 = cv.win
阅读全文
摘要:请看如下代码,执行后,思考生成的两个二维码为什么不一样? 1 # -*- coding:utf-8 -*- 2 from tkinter import * 3 from tkinter import ttk 4 from PIL import ImageTk 5 import qrcode 6 cl
阅读全文
摘要:按照官网的提示命令python -m pip install cx_Freeze --upgrade安装,不成功,报了一个错误,说cx_Freeze找不到需要的版本,还有一些警告说PIP需要升级,没理会,发现有PIP3.8命令,果断使用,成功安装: pip3.8 install cx_Freeze
阅读全文
1