提问人:Reina297 提问时间:5/12/2023 更新时间:5/12/2023 访问量:17
如何从元组中删除括号和撇号?
How would I remove the brackets and apostrophise from a tuple?
问:
我正在尝试创建一个菜单选择屏幕,该屏幕显示一个数字,然后显示 sqlite3 数据库表中的一个项目。我遇到的问题是试图摆脱最终结果的 (' 部分,以使菜单更整洁。
这是我当前的代码:
def product_categories():
product_categories_query = "SELECT Category_description \
FROM Categories \
ORDER BY Category_description"
cursor.execute(product_categories_query)
product_categories_rows = cursor.fetchall()
print(f"[1] {product_categories_rows[0]}")
print(f"[2] {product_categories_rows[1]}")
print(f"[3] {product_categories_rows[2]}")
print(f"[4] {product_categories_rows[3]}")
print(f"[5] {product_categories_rows[4]}")
print(f"[6] {product_categories_rows[5]}")
这是我得到的结果:
[1] ('Audio and Hifi',)
[2] ('Cameras and accessories',)
[3] ('Computers and accessories',)
[4] ('Gaming',)
[5] ('Mobile phones and accessories',)
[6] ('TV and Home Cinema',)
答: 暂无答案
评论
'
,