【发布时间】:2021-06-21 14:29:32
【问题描述】:
我有将这些值插入到 python 中的 sqlite 数据库的脚本:
items = [
['Lawnmower','Tool', 0, 150,'Excellent', '2012‐01‐05'],
['Lawnmower','Tool', 0, 370,'Fair', '2012‐04‐01'],
['Bike', 'Vehicle', 0, 200,'Good', '2013‐03‐22'],
['Drill', 'Tool', 0, 100,'Good', '2013‐10‐28'],
['Scarifier','Tool', 0, 200,'Average', '2013‐09‐14'],
['Sprinkler','Tool', 0, 80,'Good', '2014‐01‐06']
]
这是将值插入数据库的方法:
cur.executemany(item_sql, items)
db.commit()
我有一个这样的函数,它可以读取这些值,但它没有正确显示连字符符号,因为它可以在图像中看到。手动输入的最后一行显示正确:
def get_items():
query = '''
select * from item'''
return cursor.execute(query).fetchall()
但在 sqlite 软件中,hypen 符号显示为它应该是:
nothing wrong when viewed through sqlite software
有人知道为什么以及如何解决吗?
【问题讨论】:
-
items是您要插入数据库的 准确 值吗?看起来“连字符”字符在解释器使用的字体中无法表示,这表明它可能是其他一些看起来像连字符的字符。