import tkinter as tk
from tkinter import ttk
from tkcalendar import Calendar, DateEntry
import mysql.connector
from pandas import *
def print_sel():
strt=cal.get_date()
end=cal1.get_date()
strt1=" "+strt
end1=" "+end
print(strt)
print(end1)
mySQLconnection =
mysql.connector.connect(database='reactor1',user='sarath',password='admin')
cursor = mySQLconnection .cursor()
cursor.execute("select * from rrr")
data = DataFrame(cursor.fetchall())
data.rename(columns={0:'Date',1:'Time',2:'Temp',3:'pH',4:'Level'},inplace=True)
r1 = data.loc[:,'Date'].values
r2= data.loc[:,'Time'].values
r3=data.loc[:,'Temp'].values
r4=data.loc[:,'pH'].values
r5=data.loc[:,'Level'].values
x,y,z=0,0,0
n1,n2=[],[]
for i in range(len(r1)):
if(r1[i]>=strt1 and r1[i]<=end1):
if(r3[i]>=70):
x=x+1
n1.append(r3[i])
if(r3[i]<=60):
y=y+1
n2.append(r3[i])
print(x)
print(n1)
print(y)
print(n2)
sai=tk.Tk()
sai.title('Time Picker')
sai.geometry("+650+150")
cal = Calendar(sai,font="Arial 14")
cal.pack(fill="both", expand=True)
cal1 = Calendar(sai,font="Arial 14")
cal1.pack(fill="both", expand=True)
ttk.Button(sai, text="ok", command=print_sel).pack()
在这里,我要求用户选择开始日期和结束日期。根据选定的日期,我必须比较r3中的值并打印出来。但是它也会打印超出范围的值。 我只选择了四天,但我正在获取许多天的数据 它可以在10-19和20-29之间正常工作,如果我们选择10到25,则如果获得1和2。