如何使用套接字和Kivy解决此错误?

如何解决如何使用套接字和Kivy解决此错误?

我正在使用python plese创建一个应用程序来解决此错误 帮助

z = socket.socket()
    server_host = 'your ip'
    port = 1024
    z.connect((server_host,port))
    z.send('test'.encode())
    da = self.root.ids.date.text
    time.sleep(.2)
    sbj = self.root.ids.subject.text
    tim = self.root.ids.time.text
    dess = self.root.ids.desss.text
    z.send(sbj.encode())
    time.sleep(.2)
    z.send(tim.encode())
    time.sleep(.2)
    z.send(da.encode())
    time.sleep(.2)
    z.send(dess.encode())
    z.close()

这是我在我的应用程序中用于学生作业的功能代码,这是此功能在服务器端的代码

sub = z.recv(1024)
    sub = sub.decode()
    des = z.recv(1024)
    des = des.decode()
    tim = z.recv(1024)
    tim = tim.decode()
    date = z.recv(1024)
    date = date.decode()
    conn = sqlite3.connect('data2.db')
    cursor = conn.cursor()
    cursor.execute(f"UPDATE tests SET time = ? WHERE sub = ?",(str(tim),str(sub)))
    conn.commit()
    cursor.execute(f"UPDATE tests SET day = ? WHERE sub = ?",(str(date),str(sub)))
    conn.commit()
    cursor.execute(f"UPDATE tests SET des = ? WHERE sub = ?",(str(des),str(sub)))
    conn.commit()
    conn.close()

但是在刷新屏幕时测试没有变化 这是我的刷新功能

z = socket.socket()
    server_host = 'your ip address'
    port = 1024
    z.connect((server_host,port))
    z.send('refresh'.encode())
    math_t = (z.recv(1024).decode('utf-8'))
    math_d = (z.recv(1024).decode('utf-8'))
    math_des = (z.recv(1024).decode('utf-8'))

    bio_t = (z.recv(1024).decode('utf-8'))
    bio_d = (z.recv(1024).decode('utf-8'))
    bio_des = (z.recv(1024).decode('utf-8'))

    phy_t = (z.recv(1024).decode('utf-8'))
    phy_d = (z.recv(1024).decode('utf-8'))
    phy_des = (z.recv(1024).decode('utf-8'))

    chem_t = (z.recv(1024).decode('utf-8'))
    chem_d = (z.recv(1024).decode('utf-8'))
    chem_des = (z.recv(1024).decode('utf-8'))

    hist_t = (z.recv(1024).decode('utf-8'))
    hist_d = (z.recv(1024).decode('utf-8'))
    hist_des = (z.recv(1024).decode('utf-8'))

    civ_t = (z.recv(1024).decode('utf-8'))
    civ_d = (z.recv(1024).decode('utf-8'))
    civ_des = (z.recv(1024).decode('utf-8'))

    pbi_t = (z.recv(1024).decode('utf-8'))
    pbi_d = (z.recv(1024).decode('utf-8'))
    pbi_des = (z.recv(1024).decode('utf-8'))

    hin_t = (z.recv(1024).decode('utf-8'))
    hin_d = (z.recv(1024).decode('utf-8'))
    hin_des = (z.recv(1024).decode('utf-8'))

    geo_t = (z.recv(1024).decode('utf-8'))
    geo_d = (z.recv(1024).decode('utf-8'))
    geo_des = (z.recv(1024).decode('utf-8'))

    z.close()
    math = self.root.ids.math
    math.secondary_text = math_des
    math.tertiary_text = f'on {math_d},time: {math_t}'

    bio = self.root.ids.bio
    bio.secondary_text = bio_des
    bio.tertiary_text = f'on {bio_d},time: {bio_t}'

    chem = self.root.ids.chem
    chem.secondary_text = chem_des
    chem.tertiary_text = f'on {chem_d},time: {chem_t}'

    phy = self.root.ids.phy
    phy.secondary_text = phy_des
    phy.tertiary_text = f'on {phy_d},time: {phy_t}'

    hist = self.root.ids.hist
    hist.secondary_text = hist_des
    hist.tertiary_text = f'on {hist_d},time: {hist_t}'

    civ = self.root.ids.civ
    civ.secondary_text = civ_des
    civ.tertiary_text = f'on {civ_d},time: {civ_t}'

    pbi = self.root.ids.pbi
    pbi.secondary_text = pbi_des
    pbi.tertiary_text = f'on {pbi_d},time: {pbi_t}'

    hin = self.root.ids.hin
    hin.secondary_text = hin_des
    hin.tertiary_text = f'on {hin_d},time: {hin_t}'

    geo = self.root.ids.geo
    geo.secondary_text = geo_des
    geo.tertiary_text = f'on {geo_d},time: {geo_t}'

和刷新服务器端的代码

conn = sqlite3.connect("data2.db")

    math_t = conn.cursor()
    math_d = conn.cursor()
    math_des = conn.cursor()

    bio_t = conn.cursor()
    bio_d = conn.cursor()
    bio_des = conn.cursor()

    phy_t = conn.cursor()
    phy_d = conn.cursor()
    phy_des = conn.cursor()

    chem_t = conn.cursor()
    chem_d = conn.cursor()
    chem_des = conn.cursor()

    hist_t = conn.cursor()
    hist_d = conn.cursor()
    hist_des = conn.cursor()

    civ_t = conn.cursor()
    civ_d = conn.cursor()
    civ_des = conn.cursor()

    pbi_t = conn.cursor()
    pbi_d = conn.cursor()
    pbi_des = conn.cursor()

    hin_t = conn.cursor()
    hin_d = conn.cursor()
    hin_des = conn.cursor()

    geo_t = conn.cursor()
    geo_d = conn.cursor()
    geo_des = conn.cursor()

    math = "math"
    bio = "bio"
    phy = "phy"
    chem = 'chem'
    hist = 'hist'
    civ = 'civ'
    pbi = 'pbi'
    hin = 'hin'
    geo = 'geo'

    math_t.execute('SELECT * FROM tests WHERE sub = ?',(math,))
    math_d.execute('SELECT * FROM tests WHERE sub = ?',))
    math_des.execute('SELECT * FROM tests WHERE sub = ?',))

    bio_t.execute('SELECT * FROM tests WHERE sub = ?',(bio,))
    bio_d.execute('SELECT * FROM tests WHERE sub = ?',))
    bio_des.execute('SELECT * FROM tests WHERE sub = ?',))

    phy_t.execute('SELECT * FROM tests WHERE sub = ?',(phy,))
    phy_d.execute('SELECT * FROM tests WHERE sub = ?',))
    phy_des.execute('SELECT * FROM tests WHERE sub = ?',))

    chem_t.execute('SELECT * FROM tests WHERE sub = ?',(chem,))
    chem_d.execute('SELECT * FROM tests WHERE sub = ?',))
    chem_des.execute('SELECT * FROM tests WHERE sub = ?',))

    hist_t.execute('SELECT * FROM tests WHERE sub = ?',(hist,))
    hist_d.execute('SELECT * FROM tests WHERE sub = ?',))
    hist_des.execute('SELECT * FROM tests WHERE sub = ?',))

    civ_t.execute('SELECT * FROM tests WHERE sub = ?',(civ,))
    civ_d.execute('SELECT * FROM tests WHERE sub = ?',))
    civ_des.execute('SELECT * FROM tests WHERE sub = ?',))

    pbi_t.execute('SELECT * FROM tests WHERE sub = ?',(pbi,))
    pbi_d.execute('SELECT * FROM tests WHERE sub = ?',))
    pbi_des.execute('SELECT * FROM tests WHERE sub = ?',))

    hin_t.execute('SELECT * FROM tests WHERE sub = ?',(hin,))
    hin_d.execute('SELECT * FROM tests WHERE sub = ?',))
    hin_des.execute('SELECT * FROM tests WHERE sub = ?',))

    geo_t.execute('SELECT * FROM tests WHERE sub = ?',(geo,))
    geo_d.execute('SELECT * FROM tests WHERE sub = ?',))
    geo_des.execute('SELECT * FROM tests WHERE sub = ?',))

    z.send(math_t.fetchone()[1].encode())
    time.sleep(.2)
    z.send(math_d.fetchone()[2].encode())
    time.sleep(.2)
    z.send(math_des.fetchone()[3].encode())
    time.sleep(.2)

    z.send(bio_t.fetchone()[1].encode())
    time.sleep(.2)
    z.send(bio_d.fetchone()[2].encode())
    time.sleep(.2)
    z.send(bio_des.fetchone()[3].encode())
    time.sleep(.2)

    z.send(phy_t.fetchone()[1].encode())
    time.sleep(.2)
    z.send(phy_d.fetchone()[2].encode())
    time.sleep(.2)
    z.send(phy_des.fetchone()[3].encode())
    time.sleep(.2)

    z.send(chem_t.fetchone()[1].encode())
    time.sleep(.2)
    z.send(chem_d.fetchone()[2].encode())
    time.sleep(.2)
    z.send(chem_des.fetchone()[3].encode())
    time.sleep(.2)

    z.send(hist_t.fetchone()[1].encode())
    time.sleep(.2)
    z.send(hist_d.fetchone()[2].encode())
    time.sleep(.2)
    z.send(hist_des.fetchone()[3].encode())
    time.sleep(.2)

    z.send(civ_t.fetchone()[1].encode())
    time.sleep(.2)
    z.send(civ_d.fetchone()[2].encode())
    time.sleep(.2)
    z.send(civ_des.fetchone()[3].encode())
    time.sleep(.2)

    z.send(pbi_t.fetchone()[1].encode())
    time.sleep(.2)
    z.send(pbi_d.fetchone()[2].encode())
    time.sleep(.2)
    z.send(pbi_des.fetchone()[3].encode())
    time.sleep(.2)

    z.send(hin_t.fetchone()[1].encode())
    time.sleep(.2)
    z.send(hin_d.fetchone()[2].encode())
    time.sleep(.2)
    z.send(hin_des.fetchone()[3].encode())
    time.sleep(.2)

    z.send(geo_t.fetchone()[1].encode())
    time.sleep(.2)
    z.send(geo_d.fetchone()[2].encode())
    time.sleep(.2)
    z.send(geo_des.fetchone()[3].encode())
    z.close()
    conn.close()

如果您认为我写错了什么,请帮忙

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com(将#修改为@)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?