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]

相关文章:

  • 2021-12-20
  • 2021-12-06
  • 2021-10-07
  • 2022-02-10
  • 2021-10-18
  • 2021-10-27
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-01
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2021-12-15
  • 2022-12-23
  • 2022-01-23
相关资源
相似解决方案