UnicodeDecodeError: 'utf8' codec can't decode byte 0x9c

前端 未结 10 1895
暖寄归人
暖寄归人 2020-11-22 14:49

I have a socket server that is supposed to receive UTF-8 valid characters from clients.

The problem is some clients (mainly hackers) are sending all the wrong kind of

相关标签:
10条回答
  • 2020-11-22 15:26

    I have resolved this problem using this code

    df = pd.read_csv(gdp_path, engine='python')
    
    0 讨论(0)
  • 2020-11-22 15:28

    Just in case of someone has the same problem. I'am using vim with YouCompleteMe, failed to start ycmd with this error message, what I did is: export LC_CTYPE="en_US.UTF-8", the problem is gone.

    0 讨论(0)
  • 2020-11-22 15:29

    the first,Using get_encoding_type to get the files type of encode:

    import os    
    from chardet import detect
    
    # get file encoding type
    def get_encoding_type(file):
        with open(file, 'rb') as f:
            rawdata = f.read()
        return detect(rawdata)['encoding']
    

    the second, opening the files with the type:

    open(current_file, 'r', encoding = get_encoding_type, errors='ignore')
    
    0 讨论(0)
  • 2020-11-22 15:29

    I have solved this problem just by adding

    df = pd.read_csv(fileName,encoding='latin1')
    
    0 讨论(0)
提交回复
热议问题