随笔 - 134  文章 - 0  评论 - 0  阅读 - 42858
07 2023 档案
python适配器模式
摘要:class A: def cost(self): print('cost a')​​class B: def cost(self): print('cost b')​​class MyAdapter:​ def __init__(self, obj): self.obj = obj​ def pay 阅读全文
posted @ 2023-07-30 13:01 CJTARRR 阅读(8) 评论(0) 推荐(0) 编辑
python单例模式实现
摘要:class Singleton(object):​ def __new__(cls, *args, **kwargs): if not hasattr(cls, '_instance'): cls._instance = super(Singleton, cls).__new__(cls) retu 阅读全文
posted @ 2023-07-30 10:39 CJTARRR 阅读(6) 评论(0) 推荐(0) 编辑
mongodb索引操作
摘要:db.col.createIndex({"title":1}) 创建索引db.col.getIndexes() 查询当前索引db.col.totalIndexSize() 查询索引大小db.col.dropIndexes() 删除所有索引db.col.dropIndex("索引名称") 删除指定索引 阅读全文
posted @ 2023-07-25 09:17 CJTARRR 阅读(9) 评论(0) 推荐(0) 编辑
GIT回退版本
摘要:git reset --hard idgit push -f 阅读全文
posted @ 2023-07-25 09:16 CJTARRR 阅读(3) 评论(0) 推荐(0) 编辑
pyppeteer通过xpath定位标签
摘要:ele_handle = await page.xpath("xpath表达式") 此处的ele_handle是一个包含标签对象的列表。 通过上述方式得到的标签对象,也可以继续执行xpath,如:await ele_ele_handle[0].xpath("./div") 阅读全文
posted @ 2023-07-11 10:49 CJTARRR 阅读(340) 评论(0) 推荐(0) 编辑
python3.8安装weditor失败
摘要:解决:启用python环境编码为utf-8模式,输入这一句命令set PYTHONUTF8=1 阅读全文
posted @ 2023-07-10 11:51 CJTARRR 阅读(178) 评论(0) 推荐(0) 编辑
python多装饰器的执行顺序
摘要:装饰器实现 def outer(func): """ 自定义逻辑1 """ def inner(*args,**kwargs): """ 自定义逻辑2 """ res = func(*args,**kwargs) """ 自定义逻辑3 """ return res return inner 装饰器装 阅读全文
posted @ 2023-07-05 00:08 CJTARRR 阅读(318) 评论(0) 推荐(0) 编辑
python执行终端命令并获得输出结果
摘要:兼容windows和linux的终端执行函数 def shell_exec(cmd: str) -> str: """ 执行终端命令,输出终端打印结果 :param cmd: :return: """ with os.popen(cmd) as fp: bf = fp._stream.buffer. 阅读全文
posted @ 2023-07-01 09:04 CJTARRR 阅读(221) 评论(0) 推荐(0) 编辑
scrapy 2.x相关配置
摘要:使用pip安装scrapy之后可能并不能直接运行,会遇到各种报错,可能是依赖库的版本不兼容导致的,可能需要安装或更新以下依赖: cryptography==38.0.4​pyopenssl==22.0.0​certifi==2023.5.7 在windows python3.8+下的scrapy框架 阅读全文
posted @ 2023-07-01 08:58 CJTARRR 阅读(41) 评论(0) 推荐(0) 编辑
python lambda表达式(匿名函数)
摘要:表达式名字 = lambda 参数1,参数2,... : 前面参数组成的表达式 举例: add = lambda x,y:x+y add(3,4) 结果为:7 阅读全文
posted @ 2023-07-01 08:41 CJTARRR 阅读(8) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示