Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pymysql
- def get_item(_list, _key):
- return [i[2:4] for i in _list if _key in i]
- conn = pymysql.connect(host='localhost', user='root', password='',db='',charset='utf8')
- curs = conn.cursor()
- sql = "select * from tb_cat"
- curs.execute(sql)
- rows = list(curs.fetchall())
- print(type(rows))
- conn.close()
- print(get_item(rows, "id_coffee"))
Add Comment
Please, Sign In to add comment