自己去写的一些方法
#线上慢sql报警提示
def check_mansql():
today_url="http://10.1.21.104/index.php"
#history_url="http://10.1.21.104/index.php?begin=2020-08-10"
response=requests.request("get",url=today_url,verify=False)
list=["booking_avatar","registration_avatar","cooperation_avatar","patientsignin_avatar","exhibition_avatar","evection_avatar","cosmetology_avatar","sickmanage_avatar","comment_avatar"]
list_sql=[]
for i in range(0,len(list)):
a=list[i]
a_counts=response.text.count(a)
if a_counts > 1:
mansqltixing=a+"有线上慢sql,链接:http://10.1.21.104"+" "
list_sql.append(mansqltixing)
if list_sql:
content = "".join(list_sql)
mentioned_mobile_list = ['18210466329']
send_rebot(msgtype="text", content=content, mentioned_mobile_list=mentioned_mobile_list)
else:
pass
二次修改:
![](https://img2020.cnblogs.com/blog/1033153/202009/1033153-20200907110407859-1374041375.png)
扩展 如何判断,类型
if isinstance(A,list): 这是python提供的 方法去判断类型的
python中,判断某变量的数据类型是否为字符串,可用isinstance()函数,也可通过比较 type(x) == type(‘a’)的值来判断。
A = 123
B = [123.'A']
C = {'A':123,'B':45}
D = 1.23
E = 'abc'
isinstance(A, int) #True
isinstance(B, list) #True
isinstance(C, dict) #True
isinstance(D, float) #True
isinstance(E, str) #True
type(A)== type(1) #True
type(B)== type([]) #True