Python中文显示问题&数据库连接传参

1.Python连接mysql数据库,并且传递参数

con = MySQLdb.connect(host='***', user='root', passwd='***', db='***', port=***, charset='utf8')
cur1 = con.cursor()
cur2 = con.cursor()
cur1.execute("SELECT distinct(a6) FROM b where a2=%s ", (Id[0]))
cur2.execute("SELECT distinct(a6) FROM b where a2=%s ", (Id[1]))
program1 = set()
program2 = set()
for eachprogram1 in cur1:
program1.add(eachprogram1)
for eachprogram2 in cur2:
program2.add(eachprogram2)
cur1.close()
cur2.close()
con.close()

2.Python2存在中文打印时候的显示问题,在网上找了半天都没有解决,原来就只是需要,逐个元素的打印,不能打印list或者tuple

for each in jiao:
print each[0]

posted @ 2017-04-06 17:29  fionaplanet  阅读(542)  评论(0编辑  收藏  举报