wxpy icon indicating copy to clipboard operation
wxpy copied to clipboard

'gbk' can not encode character

Open Noel549 opened this issue 7 years ago • 11 comments

在pylab(ipython)下,我想尝试打印好友列表和给自己发一条信息,但都出现了'gbk' can not encode character 这样的UnicodeEncodeError。上网找了很多相关的方法都没有解决这个问题。我发现用这个工具的人好像都没出现过这样的问题,是环境之类的问题吗?谢谢解答。

1 2

Noel549 avatar Sep 12 '17 11:09 Noel549

应该是emoji的编码问题

onestone1879 avatar Sep 12 '17 19:09 onestone1879

python2 还是 3?

mapleflow avatar Sep 13 '17 01:09 mapleflow

@mapleflow python2.7 32bit win7

Noel549 avatar Sep 13 '17 02:09 Noel549

@onestone1879 我也这样觉得,不过利用文件助手发一条只带空格的消息也报gbk can not encode,就感觉有点怪怪的。在网上找的一些方法也不能解决。

Noel549 avatar Sep 13 '17 02:09 Noel549

用 py 3.5 + 的版本好点吧, 其他版本的兼容性差点.

mapleflow avatar Sep 13 '17 03:09 mapleflow

@mapleflow 这大概不是版本的问题吧...issue里用2.7的没见到有出现这个问题啊...

Noel549 avatar Sep 13 '17 04:09 Noel549

用 3.5,上百个群接收信息都没有过此类编码问题.

mapleflow avatar Sep 13 '17 07:09 mapleflow

@Noel549 py3和py2的字符串编码方式不同,你可以换py3试试,或者换linux,windows cmd下py2编码好像有个坑

onestone1879 avatar Sep 14 '17 01:09 onestone1879

用 vagrant 或者 docker 吧.

mapleflow avatar Sep 14 '17 01:09 mapleflow

@mapleflow @onestone1879 好的,谢谢回答

Noel549 avatar Sep 22 '17 08:09 Noel549

pythin 3.4 pycharm 里面直接运行代码就可以,pyinstaller打包成exe再运行,就不行了,"UnicodeDecodeError: ‘gbk’ codec can’t decode

duoluoxiaosheng avatar Apr 09 '20 07:04 duoluoxiaosheng