Python script receiving a UnicodeEncodeError: 'ascii' codec can't encode character

后端 未结 3 1973
南笙
南笙 2021-01-25 16:16

I have a simple Python script that pulls posts from reddit and posts them on Twitter. Unfortunately, tonight it began having issues that I\'m assuming are because of someone\'s

3条回答
  •  一个人的身影
    2021-01-25 16:57

    The problem likely arises from mixing bytestrings and unicode strings on concatenation. As an alternative to prefixing all string literals with u, maybe

    from __future__ import unicode_literals
    

    fixes things for you. See here for a deeper explanation and to decide whether it's an option for you or not.

提交回复
热议问题