如何让python机器人在不崩溃的情况下读取unicode?

如何让python机器人在不崩溃的情况下读取unicode?,python,python-3.x,github,unicode,git-bash,Python,Python 3.x,Github,Unicode,Git Bash,我目前正在使用gitbash在picarto上运行的bot,每当有人在聊天中使用emojis时,bot就会给我以下错误: Traceback (most recent call last): File "Main.py", line 107, in start await task File "E:\-\Client.py", line 76, in main await self.listen() File "E:\-\Client.py", line 17

我目前正在使用gitbash在picarto上运行的bot,每当有人在聊天中使用emojis时,bot就会给我以下错误:

    Traceback (most recent call last):
  File "Main.py", line 107, in start
    await task
  File "E:\-\Client.py", line 76, in main
    await self.listen()
  File "E:\-\Client.py", line 173, in listen
    await self.print_override(printable)
  File "E:\-\Client.py", line 436, in print_override
    print(text)
  File "C:\Users\-\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f914' in position 49: character maps to <undefined>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "Main.py", line 181, in main
    _loop.run_until_complete(start())
  File "C:\-\base_events.py", line 616, in run_until_complete
    return future.result()
  File "Main.py", line 110, in start
    print(sys.exc_info())
  File "C:\-\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f914' in position 111: character maps to <undefined>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "Main.py", line 194, in main
    print(sys.exc_info(encoding='utf-8'))
  File "C:\-\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f914' in position 173: character maps to <undefined>

During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "Main.py", line 202, in <module>
        main()
      File "Main.py", line 198, in main
        print(sys.exc_info())
      File "C:\-\cp1252.py", line 19, in encode
        return codecs.charmap_encode(input,self.errors,encoding_table)[0]
    UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f914' in position 244: character maps to <undefined>
我试图手动将encoding='utf-8'压缩到脚本中,但这也会导致脚本崩溃

我有点困惑于我需要做些什么来解决这个问题

我可以提出任何形式的建议来解决这个问题吗

目前正在使用python 3.8

--编辑--

下面是其中一个脚本的一个片段,该脚本给出了错误“cp1253.py” 它一直在为charmap错误发出叮当声的是第19行

9 class Codec(codecs.Codec):
10
11    def encode(self,input,errors='strict'):
12        return codecs.charmap_encode(input,errors,encoding_table)
13
14    def decode(self,input,errors='strict'):
15        return codecs.charmap_decode(input,errors,decoding_table)
16
17class IncrementalEncoder(codecs.IncrementalEncoder):
18    def encode(self, input, final=False):
>>>19        return codecs.charmap_encode(input,self.errors,encoding_table)[0]
20
21class IncrementalDecoder(codecs.IncrementalDecoder):
22    def decode(self, input, final=False):
23        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
24
25class StreamWriter(Codec,codecs.StreamWriter):
26    pass
27
28class StreamReader(Codec,codecs.StreamReader):
29    pass

您正在使用
print()
语句吗?您是否尝试改为写入文件?注意:当您出现编码错误时,问题是写入,而不是读取。@Nraco您可以共享您的代码片段吗?我应该从何处剪切?main.py或client.py或其他插件之一?。。。我链接的两个文本是:gitbash日志和整个usercustomize.py文件@Rohan bojja如果需要更多帮助,您需要从
Main.py
Client.py
发布代码。它应该很容易修复。在代码中的某个地方,一个
str
正在用
cp1253
字符集而不是
utf-8
字符集编码为
bytes
。您使用的是
print()
语句吗?您是否尝试改为写入文件?注意:当您出现编码错误时,问题是写入,而不是读取。@Nraco您可以共享您的代码片段吗?我应该从何处剪切?main.py或client.py或其他插件之一?。。。我链接的两个文本是:gitbash日志和整个usercustomize.py文件@Rohan bojja如果需要更多帮助,您需要从
Main.py
Client.py
发布代码。它应该很容易修复。在代码中的某个地方,
str
正在使用
cp1253
字符集而不是
utf-8
字符集编码为
bytes
9 class Codec(codecs.Codec):
10
11    def encode(self,input,errors='strict'):
12        return codecs.charmap_encode(input,errors,encoding_table)
13
14    def decode(self,input,errors='strict'):
15        return codecs.charmap_decode(input,errors,decoding_table)
16
17class IncrementalEncoder(codecs.IncrementalEncoder):
18    def encode(self, input, final=False):
>>>19        return codecs.charmap_encode(input,self.errors,encoding_table)[0]
20
21class IncrementalDecoder(codecs.IncrementalDecoder):
22    def decode(self, input, final=False):
23        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
24
25class StreamWriter(Codec,codecs.StreamWriter):
26    pass
27
28class StreamReader(Codec,codecs.StreamReader):
29    pass