python
nextvary
这个作者很懒,什么都没留下…
展开
-
基于PHP、Python 开发Alfred workflow 工具
1、实现的功能 快速生成 某文件中某接口的链路日志 查询语句 效果 : 2、原理 根据输入的条件,生成符合条件的列表 输出的格式: { "items": [ { "title": "trace go_mutual_apply ", "subtitle": "grep `tail -1000 *go_mutual_apply*.log_json.20200512 |grep * | tail -1 |jq \".spanid\原创 2020-05-12 14:53:16 · 517 阅读 · 0 评论 -
简易报警监控 tail -f 最后一条日志,通知到钉钉
支持文件删除后重新监控日志 支持手动编辑文件后,继续报警 多进程,支持监听多个日志文件,自定义定义群 # coding=utf-8 import json import os import sys import time from multiprocessing import Process, Queue, Pool import requests class Tail(object):...原创 2020-01-20 19:10:27 · 466 阅读 · 0 评论 -
正则
import re #从零开始匹配 result=re.match('abc','abcde') print(result.group()) #匹配ip result=re.match("([0-9]{1,3}\.){3}\d{1,3}",'192.168.2.23') print(result.group()) #找到所有的数组 必须要1个以上 所以不能* result=re.findall(原创 2017-04-12 10:57:40 · 420 阅读 · 0 评论 -
configparser模块
import configparser config=configparser.ConfigParser() #DEFAULT 全局都有 config['DEFAULT']={ 'ServerAliveInterval':'45', 'Compression':'yes', 'CompressionLevel':'9 ' } config['bitbucket.org'原创 2017-04-14 16:25:49 · 372 阅读 · 0 评论 -
模块
import os,sys,shutil,zipfile,shelve ##os文件模块 print(os.environ['os']) os.system('dir') #执行系统命令 a=os.popen('dir').read() #执行dir命令 当做临时文件,然后read() print(a,'\n-------------------------') print(os.stat('in原创 2017-04-13 17:46:48 · 412 阅读 · 0 评论 -
logger日志模块
import logging # # logging.basicConfig(filename='mylog.log',level=logging.WARNING, # format='%(asctime)s %(message)s',datefmt='%Y-%m-%d %H:%M:%S') # logging.warning("user [laowang...原创 2017-04-17 11:14:47 · 418 阅读 · 0 评论 -
类 静态方法,属性,类方法
class Animal: def __init__(self,name,num): self.name=name #实例的属性 self.num=num#实例的属性 has_animal='long' @classmethod #类方法,不能访问实例属性,里面不能写self.name 这是实例属性 def talk(self):原创 2017-04-21 10:21:15 · 284 阅读 · 0 评论 -
yii2 redis队列,数据库表锁实现,点赞功能(10s内只可以点一次)
public function actionLike1(){ $data = @json_decode(file_get_contents("php://input","r"),true); $topic_id=$data['topic_id']; $redis = Yii::$app->redis; $ip=Yii::$app->requ原创 2017-09-26 18:09:05 · 2207 阅读 · 0 评论