PyMySQL 獲取資料 'utf-8' codec can't decode byte 0xed in position 2: 錯誤

G8bao7發表於2020-04-28

轉載:  https://my.oschina.net/pallormoon/blog/629807


解決:

PyMySQL 包目錄下的connections.py檔案1232行左右


     def _read_row_from_packet(self, packet):          row = []           for  encoding, converter  in  self.converters:               data  = packet.read_length_coded_string()               if   data   is  not None:                   if  encoding  is  not None:                       data  =  data .decode(encoding)                  

                if  DEBUG: print( "DEBUG: DATA = " data )                   if  converter  is  not None:                       data  = converter( data )              row.append( data )           return  tuple(row)


data = data.decode(encoding)

改為

data = data.decode(encoding,'ignore')


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26250550/viewspace-2688950/,如需轉載,請註明出處,否則將追究法律責任。

相關文章