摘要: 正则表达式进行分组匹配,例如: 当我想匹配字符串末尾的!,不存在时,给一个默认值为not found import re str1 = "hello word!" str2 = "hello word" parttern = '(?P<first>hello) (?P<sec>word)(?P<th 阅读全文
posted @ 2023-02-14 16:57 TasteL 阅读(93) 评论(0) 推荐(0) 编辑
摘要: split 最常用的方法 re.split splitlines 按行进行分割 partition # 使用split进行分割是,若分割符合不存在,会返回一个列表,含有一个元素 'abc'.split('d') # ['abc'] # partition会返回一个三元组 'abc'.partitio 阅读全文
posted @ 2022-11-29 14:54 TasteL 阅读(498) 评论(0) 推荐(0) 编辑
摘要: 转载地址:https://www.ucloud.cn/yun/37950.html 众所周知,在 python 中可以使用 exec 函数来执行包含 python 源代码的字符串: >>> code = """ ...: a = "hello" ...: print(a) ...: """ >>> 阅读全文
posted @ 2022-08-22 18:22 TasteL 阅读(197) 评论(0) 推荐(0) 编辑
摘要: a或b只取一个值,而不是没有值时为None c = re.search('(?P<c>[(?P<a>1)|(?P<b>2)])','123') b.groupdict() 输出 {'c': '1'} c = re.search('(?P<c>[(?P<a>1)|(?P<b>2)])','23') b 阅读全文
posted @ 2022-06-22 16:09 TasteL 阅读(344) 评论(0) 推荐(0) 编辑
摘要: 背景 项目在内网部署,本来想使用nginx部署,因为某些原因,所以采用了Django+uwsgi+vue部署的部署方式 部署流程 Vue打包 不熟悉VUE,按照给的步骤进行 执行npm run lint-fix 执行npm run build 将生成的包放到Django项目根目录的static目录下 阅读全文
posted @ 2022-01-19 18:20 TasteL 阅读(816) 评论(0) 推荐(0) 编辑
摘要: 注: 若使用数据局关联关系,请参考这里 models.py class DeviceInfo(BaseModel): name = models.CharField(max_length=128, blank=True, null=True, help_text='名称') ip = models. 阅读全文
posted @ 2022-01-06 19:08 TasteL 阅读(356) 评论(0) 推荐(0) 编辑
摘要: #修改server监听端口 agent->server agent端 修改ServerActivevi /etc/zabbix/zabbix_agentd.conf ServerActive=x.x.x.x:10010 # ip:port 重启服务 systemctl restart zabbix- 阅读全文
posted @ 2021-05-08 10:24 TasteL 阅读(2454) 评论(0) 推荐(0) 编辑
摘要: from sqlalchemy import literal query = db_session.query(AlarmRule.id, literal('value').label('num')).filter(AlarmRule.id==1).first() query.num u'value 阅读全文
posted @ 2021-04-29 18:16 TasteL 阅读(635) 评论(0) 推荐(0) 编辑
摘要: ###日志的配置 logger.py import logging logger = logging.getLogger() logger.setLevel(logging.INFO) # log_path ='' log_name = 'loger.log' fh = logging.FileHa 阅读全文
posted @ 2021-04-26 15:46 TasteL 阅读(1681) 评论(0) 推荐(0) 编辑
摘要: sqlalchemy获取模型属性 Pop为模型类 import Pop getattr(Pop,'uuid') <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x36e8410> Pop.uuid <sqlalchemy.orm 阅读全文
posted @ 2021-04-07 10:00 TasteL 阅读(3356) 评论(0) 推荐(0) 编辑