- 博客(110)
- 资源 (6)
- 收藏
- 关注
原创 AttributeError: AttributeError: module ‘PIL.Image‘ hamodule ‘PIL.Image‘ has no attribute ‘ANTIALIAS‘
将代码里的 Image.ANTIALIAS 换成 Image.Resampling.LANCZOS。
2025-04-05 17:39:04
71
原创 python实现提取json字符串的部分值
def test(): list_map = [] data = [{'a':a1,"b":b1,"c":c1},{'a':a2,"b":b2,"c":c2},{'a':a3,"b":b3,"c":c3}] for item in data: a = item['a'] b = item['b'] list_map.append({"a":a,"b":b}) return list_map
2022-03-17 10:13:54
1258
原创 批量生成条形码并写入到excel文件
import randomfrom functools import reducefrom apitest.common import readExceldef get_imei(): # 由15位数字组成,前6位(TAC)是型号核准号码,代表手机类型。接着2位(FAC)是最后装配号,代表产地。后6位(SNR)是串号,代表生产顺序号。最后1位(SP)是检验码。 # 1.将偶数位数字分别乘以2,分别计算个位数和十位数之和;2.将奇数位数字相加,再加上上一步算得的值;3.如果得出的.
2022-03-14 20:11:34
524
原创 python生成条形码(不限制长度)
import osimport barcodefrom barcode.writer import ImageWriterimport matplotlib.pyplot as plt # plt 用于显示图片import matplotlib.image as imagename = barcode.generate(u'code128', u'363287468748243', writer=ImageWriter(), output='barcode_png')im = image..
2022-03-14 20:08:46
5944
原创 Excel xlsx file; not supported两种解决办法
原因:xlrd1.2.0之后的版本不支持xlsx格式办法一:卸载新版本 pip uninstall xlrd安装老版本:pip install xlrd=1.2.0
2021-06-07 15:20:21
73417
8
原创 Python Json与Object对象互转
参考链接:https://blog.youkuaiyun.com/jun118166/article/details/107034655https://www.cnblogs.com/alettarit/p/10829103.html此方法的目的是为了动态修改json参数# -*- coding:utf-8 -*-# @Time : 2021/5/26 3:58 下午# @Author: lixia# @File : test_json_to_object.py# @descripition
2021-05-26 16:40:17
950
原创 python跨层级目录访问文件实现
在最底层实现访问文件的方法里获取根目录,然后拼接目标文件目录,需要访问的传入文件名即可例如:import osbase_dir = str(os.path.dirname(os.path.dirname(__file__)))base_path = base_dir+'/resource/'def test(filename="test.xlsx") filepath = base_path+filename try: file = xlrd.open_wo
2021-01-04 10:33:43
847
原创 Python3实现requests请求下载url文件到指定目录
python2 实现参考:https://blog.youkuaiyun.com/tankpanv/article/details/100731081python3版本def urldownload(url,filename=None): """ 下载文件到指定目录 :param url: 文件下载的url :param filename: 要存放的目录及文件名,例如:./test.xls :return: """ down_res = requests
2020-12-08 15:31:14
17888
1
原创 正则表达式常用属性(python版)
re模块1.compile使用任何可选的标记来编译正则表达式的模式,然后返回一个正则表达式对象2.match 如果匹配成功,就返回匹配对象;如果失败,就返回 None3.search使用可选标记搜索字符串中第一次出现的正则表达式模式。如果匹配成功,则返回匹4.findall 查找字符串中所有(非重复)出现的正则表达式模式,并返回一个匹配列表4.finditer 返回一个迭代器,多用于遍历内容,校验返回内容,进而做其他操作5.split(pattern,string,...
2020-11-20 15:27:59
260
原创 Pyhton pip批量安装第三方库requirements.txt使用
pip freeze > requirements.txt (导出依赖到文件)pip install -r requirements.txt (安装文件中的所有依赖)requirements.txt文件中配置格式参考async-timeout==3.0.1attrs==20.1.0autopep8==1.5.4backcall==0.2.0backports-abc==0.5beautifulsoup4==4.9.1版本更新是需要及时修改配置文件中的版本号...
2020-11-16 09:56:35
638
原创 python茶话会学习解决问题:data argument must be byte-ish (%r)‘
参考:待csdn收藏服务恢复后添加,或者自行去找可能的报错包含但不限于:error: uncaptured python exception, closing channel <__main__.ChatSession connected 127.0.0.1:61630 at 0x108d2b640> (<class 'TypeError'>:argument should be integer or bytes-like object, not 'str' [/usr/lo
2020-11-09 10:29:58
1053
原创 python生成so库
参考:https://blog.youkuaiyun.com/weixin_44745717/article/details/89381469安装Cython实现setup.py文件from setuptools import setupfrom Cython.Build import cythonize## setup(name='Hello',# version='1.0',# description='A simple example',# auth.
2020-10-28 19:26:06
1012
原创 python打包
1.安装Setuptools编写安装脚本from setuptools import setup setup(name='Hello', version='1.0', description='A simple example', author='Magnus Lie Hetland', py_modules=['hello'])保证此文件所在目录存在hello.py文件python setup.py 执行安装脚本python setup.py build 创建...
2020-10-28 17:48:00
210
原创 Mac系统Jython安装与使用
参考:https://blog.youkuaiyun.com/HUANGQIN19880508/article/details/845236081.安装和配置java环境,参考:https://blog.youkuaiyun.com/done58/article/details/511380572.安装python3.安装homebrew,通过brew安装brew install jython4.pycharm配置参考:https://my.oschina.net/u/3289715/blog/222140
2020-10-28 14:39:26
1177
1
原创 python装饰器传参
参考:https://www.cnblogs.com/serpent/p/9445592.html目的:执行一次方法,将方法的某个数据记录到日志 def log_info(func): def make_decorater(*args,**kwargs): log_string = func.__name__+" was called" info = func(*args,**kwargs) with o
2020-09-15 11:04:08
155
原创 python mock
from unittest.mock import patchdef test_preprocess(self): ... def test_sort(self): ... def test_postprocess(self): ... @patch('%s.preprocess')@patch('%s.sort')@patch('%s.postprocess')def test_work(self,mock_post_process, m..
2020-09-11 10:10:06
146
原创 python unittest报错TypeError: ‘str‘ object is not callable in get_test_id_with_description test_id
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pycharm/teamcity/unittestpy.py", line 40, in get_test_id_with_description test_id = test.id()TypeError: 'str' object is not callable原因是setUpClass定义了id和unittest定义的id冲突了,修改id为其他名...
2020-09-10 17:38:51
487
原创 python3数据库使用
sudo apt-get install python3-devpip install mysqlclientimport MySQLdbdef test_pymysql(): conn = MySQLdb.connect( host='localhost', port=3306, user='your_username', passwd=your_password’, db='mysql' )..
2020-09-09 08:35:57
183
原创 Cypress使用npm启用时报Error: Cannot find module ‘minimist‘
使用sudo进行安装sudo npm install minimist然后报哪个安装按个,直到不再报错,成功打开登录页面
2020-08-28 11:02:31
3451
原创 继承unittest.TestCase后使用__init__方法
参考:https://www.jianshu.com/p/9833f251e566注意:methodName不要赋值,否则test不生效import unittestclass UTcase(unittest.TestCase): def __init__(self,methodName,b="nbbbb"): super(UTcase,self).__init__(methodName) self.b=b def setUp(self,a
2020-08-24 14:28:01
2201
原创 pycharm设置类注释和方法注释
类注释设置:https://www.cnblogs.com/yoyoblogs/p/11268366.html$ {PROJECT_NAME} - 当前项目的名称。$ {NAME} - 在文件创建过程中在“新建文件”对话框中指定的新文件的名称。$ {USER} - 当前用户的登录名。$ {DATE} - 当前的系统日期。$ {TIME} - 当前系统时间。$ {YEAR} - 今年。$ {MONTH} - 当月。$ {DAY} - 当月的当天。$ {HOUR} - 目前的小时。$ {M
2020-08-14 14:23:46
3314
原创 python中字典查找不存在的值时设置默认值以及拷贝,索引
get使用必须用于键值对形式的字典,比如:{‘Price': 2373, 'Valid': True, 'Name': '小米'}dict.get(key1,key2) 如果key存在,去key1的值,如果key1不存在,取key2的值,key2也可以直接赋值例如: try: data=dict(r['data'][0]) # origFinalPrice=r['data'][0]['origFinalPrice'] # origlCom.
2020-07-24 10:22:56
4899
原创 mysql使用IF进行判定条件查询
IF(条件,结果1,结果2)条件为真,执行结果1,否则执行结果2select count(*) from table where status in (0,1) and type=1 and IF(status=1,id=1,id is null);case使用,适用于设置查询结果,select * from table where state in (3,1) and type=1 and (case when state=1 then name='test1' else name=
2020-07-22 20:24:51
8331
原创 git上传文件夹后无法点击进入
参考:https://www.cnblogs.com/banbosuiyue/p/12674778.htmlgit bash执行 git rm -r --cached "灰色文件夹的名称"删除本地文件夹隐藏的.git文件重新上传即可
2020-07-09 16:24:45
2355
原创 Jmeter连接数据库以及查询结果作为变量使用
参考:https://www.jianshu.com/p/e23ab3a730b5注意:database url:jdbc:mysql://localhost:3306?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTCmysql-connector-java-*-bin.jar 下载地址:https://mvnrepository.com/下载jar包参考:https://blog.youkuaiyun.com/panruo
2020-05-22 11:20:48
727
原创 通过maven依赖下载各种依赖jar包,不限于mysql-connector-java-5.1.20-bin.jar
参考:http://www.mamicode.com/info-detail-2516298.html?__cf_chl_jschl_tk__=a96775db16849c2f445439708f963f899cc56083-1590059703-0-AZAmyB-o9059T5Zej0kz9j5y2Hs189Bb4dTp1hLLT_WEYHFsNK7qxc5x2VesUbT0GIsU5xL1DNMSumZhDB4yiFsePTSL2cq1zafxgCBgH6BSYIQ9V1cmW9ia41tB25si
2020-05-21 19:22:52
1161
原创 charles进行弱网测试
全局弱网设置个别网址限速设置关于网速的选择Bandwidth(带宽)、Utilistation(利用百分比)、Round-trip(往返延迟)、MTU(最大传输单元)3G:300k-2Mbps左右2.5G(GPRS)一般在100kbps2G(GSM)一般在5-9kbps弱网、2G、3G建议的上下行速率如下,同时还可以控制丢包率的数据网络 上行 下行弱网 10 ...
2020-05-13 19:04:42
8649
原创 flask数据库初始化提示:WARNING: This is a development server. Do not use it in a production deployment.
解决方法:将app.run()改为manager.run()from flask_script import Managermanager=Manager(app)if __name__ == "__main__": # db.create_all() # app.run(debug=False) #开发者模式 manager.run() #非开发者模式执行结果
2020-05-09 09:49:35
16126
原创 Django运行报错:RuntimeError: cryptography is required for sha256_password or caching_sha2_password
https://segmentfault.com/a/1190000019642892执行
2020-05-05 12:16:49
644
原创 Bat实现指订设备安装应用
@echo onadb uninstall com.test.packageadb shell rm -rf sdcard/com.test.packageEcho 请选择:204 287 01S 031Echo.Set /p var=请选择:if /i %var%==204 (set sn=123456)if /i %var%==287 (set sn=12345612)...
2020-04-26 09:19:10
203
原创 python实现form-data格式文件/非文件上传
文件格式上传方法 def test_upload_file(self): url = "http://www.baidu.com/" files = {'file': ('test.xls', open("test.xls", 'rb'), 'application/vnd.ms-excel', {'Expires': '0'})} he...
2020-04-03 16:44:43
2430
1
原创 django删除已创建的数据库
删除以上地方后,再重新执行即可python manage.py makemigrationspython manage.py migrations老版本操作参考:https://www.cnblogs.com/xiaozhiqi/p/11120541.html
2020-03-28 13:02:05
1562
原创 Python实现md5加密和使用HmacSHA256算法哈希进行sha256加密
# 用md5加密,md5(原始secret+时间戳(yyyy-MM-dd格式)),16进制小写形式返回def get_encryptedSecret(secret): currentDate = time.strftime("%Y-%m-%d", time.localtime(time.time())) print(currentDate) md5 = hashlib.m...
2020-03-05 09:32:11
2972
拖动文件上来安装- 指订设备安装.bat
2020-04-29
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人