gpt4 book ai didi

python - 用 python 更改 td 类

转载 作者:行者123 更新时间:2023-11-28 08:21:32 26 4
gpt4 key购买 nike

您好,我有执行 sql 查询的 Python 代码。然后我把它放在 html 表中。我已经为 html td 制作了 css。我只需要用这个 pyton 改变 html TD 类来改变 td 行的颜色。

#!/opt/nagios/python/bin/python
# -*- coding: cp1251 -*-

import sys
import errno
import psycopg2

not_needed = ['Ðàäèîïîêðûòèå', 'Êîíòåíò-óñëóãè', 'Ïðîåêò NPS - æàëîáû', 'Ïåðåêëþ÷åíèå ñ Àóòñîðñèíãà']

conn = psycopg2.connect(database="statistic", user="foris-mscp", password="foris-mscp")
cur = conn.cursor()

if len(sys.argv) != 5 or (sys.argv[1] != "all" and not sys.argv[1].isdigit()) or not sys.argv[2].isdigit() or not sys.argv[3].isdigit() or sys.argv[4] not in ["warning", "critical"]:
print "Wrong or empty argument(s) given"
sys.exit(2)
else:
warn_threshold = int(sys.argv[2])
crit_threshold = int(sys.argv[3])
current_check = sys.argv[4]

ex_code = 0
if current_check == "warning":
ex_code = 1
where_statement = "complains_qty >= %s AND complains_qty < %s" % (warn_threshold, crit_threshold)

elif current_check == "critical":
ex_code = 2
where_statement = "complains_qty >= %s" % (crit_threshold)

if sys.argv[1] == "all":
#ïðîâåðÿåì âñå æàëîáû
cur.execute("SELECT subcategory_name, complains_qty FROM cms_data_view WHERE %s AND dt IN (SELECT max(dt) FROM cms_data_view GROUP BY subcategory_id)" % (where_statement))
if cur.rowcount > 0:
result = []
for row in cur.fetchall():
if(row[0] not in not_needed):
result.append("Ïî óñëóãå '%s' çàôèêñèðîâàíî %s æàëîá" % (row[0], row[1]))

if len(result) > 0:
print "<br>".join(result)
sys.exit(ex_code)
else:
sys.exit(0)
else:
cur.execute("SELECT subcategory_name, complains_qty FROM cms_data_view WHERE subcategory_id = %s AND %s AND dt IN (SELECT max(dt) FROM cms_data_view GROUP BY subcategory_id)" % (int(sys.argv[1]), where_statement))
if cur.rowcount > 0:
result = []
for row in cur.fetchall():
result.append("Ïî óñëóãå '%s' çàôèêñèðîâàíî %s æàëîá" % (row[0], row[1]))

if len(result) > 0:
print "<br>".join(result)
sys.exit(ex_code)
else:
sys.exit(0)

我试着把它放在这里 - print "<br> <td class="statusWARNING>".join(result) 但它不起作用。

最佳答案

我认为 statusWARNING 之前的引号是把事情搞砸了。尝试用斜杠转义它\

cur.execute("SELECT subcategory_name, complains_qty FROM cms_data_view WHERE subcategory_id     = %s AND %s AND dt IN (SELECT max(dt) FROM cms_data_view GROUP BY subcategory_id)" % (int(sys.argv[1]), where_statement))
if cur.rowcount > 0:
result = []
for row in cur.fetchall():
result.append("По услуге '%s' зафиксировано %s жалоб" % (row[0], row[1]))

if len(result) > 0:
print "<br> <td class=\"statusWARNING>".join(result)
sys.exit(ex_code)
else:
sys.exit(0)

关于python - 用 python 更改 td 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28740226/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com