python用户输入的是q吗编码_python3中控制台编码问题.....

在控制台输出一个列表,结果报编码错误..

E:\weixin\itchat>python test.py

Login successfully as 一二三

Start auto replying

1111

Traceback (most recent call last):

File "test.py", line 27, in

itchat.run()

File "E:\Program Files (x86)\Python35-32\lib\site-packages\itchat\__init__.py", line 120, in run

configured_reply()

File "E:\Program Files (x86)\Python35-32\lib\site-packages\itchat\__init__.py", line 96, in configured_reply

if replyFn: send(replyFn(msg), msg.get('FromUserName'))

File "test.py", line 8, in text_reply

print(itchat.get_chatrooms())

UnicodeEncodeError: 'gbk' codec can't encode character '\U0001f338' in position 2739: illegal multibyte sequence

然后用了decode还报错,不知道该怎么办了

Login successfully as 一二三

Start auto replying

1111

Traceback (most recent call last):

File "test.py", line 28, in

itchat.run()

File "E:\Program Files (x86)\Python35-32\lib\site-packages\itchat\__init__.py", line 120, in run

configured_reply()

File "E:\Program Files (x86)\Python35-32\lib\site-packages\itchat\__init__.py", line 96, in configured_reply

if replyFn: send(replyFn(msg), msg.get('FromUserName'))

File "test.py", line 9, in text_reply

print(qun.decode('GBK'))

AttributeError: 'list' object has no attribute 'decode'

源码如下

#coding=utf8

import itchat, time

from itchat.content import *

@itchat.msg_register([TEXT, MAP, CARD, NOTE, SHARING])

def text_reply(msg):

print("1111")

qun=itchat.get_chatrooms()

print(qun.decode('GBK'))

itchat.send('%s: %s' % (msg['Type'], msg['Text']), msg['FromUserName'])

@itchat.msg_register([PICTURE, RECORDING, ATTACHMENT, VIDEO])

def download_files(msg):

msg['Text'](msg['FileName'])

return '@%s@%s' % ({'Picture': 'img', 'Video': 'vid'}.get(msg['Type'], 'fil'), msg['FileName'])

@itchat.msg_register(FRIENDS)

def add_friend(msg):

itchat.add_friend(**msg['Text']) # 该操作会自动将新好友的消息录入,不需要重载通讯录

itchat.send_msg('Nice to meet you!', msg['RecommendInfo']['UserName'])

@itchat.msg_register(TEXT, isGroupChat=True)

def text_reply(msg):

if msg['isAt']:

itchat.send(u'@%s\u2005I received: %s' % (msg['ActualNickName'], msg['Content']), msg['FromUserName'])

itchat.auto_login(True)

itchat.run()

请大神指点,应该怎么做才能输出

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值