csv reader utf-8报错:strict 改为ignore

class BufferedIncrementalDecoder(IncrementalDecoder):
    """
    This subclass of IncrementalDecoder can be used as the baseclass for an
    incremental decoder if the decoder must be able to handle incomplete
    byte sequences.
    """
    def __init__(self, errors='ignore'):
        IncrementalDecoder.__init__(self, errors)
        # undecoded input that is kept between calls to decode()
        self.buffer = b""

 

    def decode(self, input, final=False):
        # decode input (taking the buffer into account)
        data = self.buffer + input
        try:
            (result, consumed) = self._buffer_decode(data, self.errors, final)
            # keep undecoded input until the next call
            self.buffer = data[consumed:]
        except:
            result=""
        return result
                        

最终解决方法如上

posted @ 2023-08-17 11:48  myrj  阅读(10)  评论(0编辑  收藏  举报