conn = pymysql.connect(host='192.168.x.xxx', user='xxx', passwd='xxx', db='hello') # 连接数据库
cur = conn.cursor() # 创建游标
sql = 'select content from text limit 0,10'
count = cur.execute(sql) # 执行sql语句查询数据,返回值是受影响的行数
text = cur.fetchall() # 返回数据
print text
cur.close() # 关闭游标
conn.close() # 关闭连接
打印结果
?????????????????????????????�??????�????????�??????????????????
只需要添加指定charset=‘utf8’
conn = pymysql.connect(host='192.168.x.xxx', user='xxx', passwd='xxx', db='hello',charset='utf8')
打印结果
陈巨星改打中后卫并且要去费伦斯试训的事情很快就在里斯本竞技青年队里传开了。