Closed logbird closed 7 years ago
可已经show_image注释掉手动打开tmp下的二维码文件; 求问:bot.py,使用nohup后报错: Traceback (most recent call last): File "/home/wxBot/wxbot.py", line 774, in proc_msg self.handle_msg(r) File "/home/wxBot/wxbot.py", line 747, in handle_msg self.handle_msg_all(message) File "bot.py", line 71, in handle_msg_all self.send_msg_by_uid(self.tuling_auto_reply(msg['user']['id'], msg['content']['data']), msg['user']['id']) File "bot.py", line 45, in tuling_auto_reply print ' ROBOT:', result UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-12: ordinal not in range(128)
@liuwons 这个问题有解没?
@logbird @WWLoveBasketball 推荐使用screen后台运行。nohup方式运行是没有办法终端输出二维码的,所以会报错。
详细可以参考 Macintosh 或者 GNU/Linux 下 screen 命令的使用方式。
@NHibiki 谢谢,今天使用screen的方式启动这个脚本,发现依然会出现这个问题。
@logbird 啊 不好意思之前没有看全 这是编码问题 强制python默认使用utf8就好了
启动写在最前面 sys.setdefaultencoding('utf8')
如果还不好就看看vps的LC_ALL对不对
完美解决。。多谢 @NHibiki
比如使用 nohup 或者 作为守护进程的方式执行,程序就无法执行了。