"UnicodeEncodeError:'latin-1' codec can't encode character ..."

    This is because MySQLdb normally tries to encode everything to latin-1. This can be fixed by executing the following commands right after you've etablished the connection:

意思就是MySQLdb正常情况下会尝试将所有的内容转为latin1字符集处理

所以处理方法就是,设置连接和游标的charset为你所希望的编码,如utf8。

db.set_character_set('utf8')
dbc.execute('SET NAMES utf8;') dbc.execute('SET CHARACTER SET utf8;')
dbc.execute('SET character_set_connection=utf8;')

db是connection连接,dbc是数据库游标

http://stackoverflow.com/questions/3942888/unicodeencodeerror-latin-1-codec-cant-encode-character

最新文章

  1. 手机浏览器浏览WebApp弹出的键盘遮盖住文本框的解决办法
  2. Swift 和 C# 的语法比较
  3. ES6之let(理解闭包)和const命令
  4. Oracle的分页查询
  5. MyBatis插入多条
  6. PHP实现获得一段时间内所在的所有周的时间
  7. 本地或者是koala软件编译less文件为css
  8. shell命令:echo命令详解
  9. 移动支付之智能IC卡与Android手机进行NFC通信
  10. WebForm 控件(一)、连接数据库
  11. Go 从入门到精通(三)字符串,时间,流程控制,函数
  12. 201521123106 《Java程序设计》第8周学习总结
  13. python生成随机图形验证码
  14. Ambari自定义Service
  15. Python实现矿池
  16. vue(v-html)和scss的使用问题
  17. DirectX using C++_error X3539:ps1_x is no longer supported...解决方案
  18. 转载:分布式文件系统 - FastDFS 在 CentOS 下配置安装部署(1)
  19. 浅谈table、form 标签
  20. GO1.6语言学习笔记2-安装配置及代码组织

热门文章

  1. html——行内元素、块元素、行内块元素
  2. Pycharm:debug调试时使用参数
  3. 06--ubuntu的sqlite安装
  4. python笔记之发送邮件
  5. centOS Linux下用yum安装mysql
  6. SVN的一些操作
  7. LINUX -- pthread_detach()与pthread_join()
  8. What is the difference between rhel 6 and rhel7
  9. 准备MPI编程环境——Visual Studio
  10. git连接github mac