07 2023 档案

摘要: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)
摘要: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)
摘要:db.col.createIndex({"title":1}) 创建索引db.col.getIndexes() 查询当前索引db.col.totalIndexSize() 查询索引大小db.col.dropIndexes() 删除所有索引db.col.dropIndex("索引名称") 删除指定索引 阅读全文
posted @ 2023-07-25 09:17 CJTARRR 阅读(21) 评论(0) 推荐(0)
摘要:git reset --hard idgit push -f 阅读全文
posted @ 2023-07-25 09:16 CJTARRR 阅读(5) 评论(0) 推荐(0)
摘要:ele_handle = await page.xpath("xpath表达式") 此处的ele_handle是一个包含标签对象的列表。 通过上述方式得到的标签对象,也可以继续执行xpath,如:await ele_ele_handle[0].xpath("./div") 阅读全文
posted @ 2023-07-11 10:49 CJTARRR 阅读(363) 评论(0) 推荐(0)
摘要:解决:启用python环境编码为utf-8模式,输入这一句命令set PYTHONUTF8=1 阅读全文
posted @ 2023-07-10 11:51 CJTARRR 阅读(194) 评论(0) 推荐(0)
摘要:装饰器实现 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 阅读(358) 评论(0) 推荐(0)
摘要:兼容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 阅读(229) 评论(0) 推荐(0)
摘要:使用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 阅读(56) 评论(0) 推荐(0)
摘要:表达式名字 = lambda 参数1,参数2,... : 前面参数组成的表达式 举例: add = lambda x,y:x+y add(3,4) 结果为:7 阅读全文
posted @ 2023-07-01 08:41 CJTARRR 阅读(8) 评论(0) 推荐(0)