V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
maga
V2EX  ›  问与答

有办法让 python mysqldb 取出是 unicode 编码而不是 utf8 吗

  •  
  •   maga · Jun 15, 2014 · 3170 views
    This topic created in 4343 days ago, the information mentioned may be changed or developed.
    我用mysqldb 存入与取出都是utf8编码。 但python内部是unicode的,所以每次我都还要将从数据库取出的数据转换成unicode, 很是麻烦与低效, 有什么办法让mysqldb取出的就是unicode编码的吗?


    def _dict_to_unicode(self, d):
    d = json.dumps(d, ensure_ascii = False)
    d = json.loads(d)
    return d
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   6316 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 52ms · UTC 02:39 · PVG 10:39 · LAX 19:39 · JFK 22:39
    ♥ Do have faith in what you're doing.