在tkinterpython语句INSERT to SQLite with field Double data type中,不能隐式地将float转换为string

2024-10-01 17:39:41 发布

您现在位置:Python中文网/ 问答频道 /正文

在Tkinter中,Python 3.4 SQLite3:库塔配电箱真的

Tkinter声明:

cur.execute ( "INSERT INTO lista_clientes ( cuota, nit, nombre ) VALUES(" + lcuota.get() + "," + \
               + "'" + lnit.get() + "'" + ","  + "'" + lnombre.get() + "'" + ")" );
conn.commit()

lcuota = DoubleVar()

TypeError: Can't convert 'float' object to str implicitly

什么错误导致lcuota.get()?你知道吗


Tags: 声明executegettkintersqlite3insertvaluescur
1条回答
网友
1楼 · 发布于 2024-10-01 17:39:41

lcuota.get()返回float值,在将其与字符串连接之前,必须使用str(lcuota.get())将其键入字符串类型。你知道吗

试试这个:

cur.execute ( "INSERT INTO lista_clientes ( cuota, nit, nombre ) VALUES(" + str(lcuota.get()) + "," \
               + "'" + str(lnit.get()) + "'" + ","  + "'" + str(lnombre.get()) + "'" + ")" );

相关问题 更多 >

    热门问题