So, I am trying to understand this:
c.execute('SELECT * FROM random ORDER BY id')
line = c.fetchall()
for row in line:
text.insert(END, row)
text.insert(END, '\n')
With the Sqlite3 list:
1 7
2 94
3 15
(The first number is a simple id (line number for example) and the second number is just a random number) Now, I have a problem...When I add the the id 11 and when i print row it gives me this:
('1', 7)
('11', 60)
('2', 94)
('3', 15)
The number 11 was supposed to appear last, right?
Any help?
看起来列id
的类型为char
,因此顺序是正确的,因为字符串11
小于2。您应将列ID的类型更改为int
或者必须先转换id才能订购
在输出中,您的引号包含11: '11'
-这表示它是11的字符串。以某种方式,您需要确保将整数存储在id字段中。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.