简体   繁体   English

Python utf8编解码器无法解码位置103的字节0x80:无效的起始字节

[英]Python utf8 codec can't decode byte 0x80 in position 103:invalid start byte

Here is my code and sample of my csv file and after I run the code, the error shows up utf8 codec can't decode byte 0x80 in position 103:invalid start byte and if anyone could help 这是我的代码和我的csv文件的示例,运行代码后,错误显示utf8编解码器无法解码位置103的字节0x80:无效的起始字节,并且有人可以帮助 这是文件的例子

import csv
import pandas as pd
import numpy as np
import os
import sys
h = pd.read_csv('C:/Users/Desktop/Result.csv')

sentences = h['Mention']

def check_it(sentences):
    if 'camera' in sentences:
        return "Camera"
    if 'Camera' in sentences:
        return "Camera"

    if 'display' in sentences:
        return "Display"
    if 'Display' in sentences:
        return "Display"

    if 'battery' in sentences:
        return "Battery"
    if 'Battery' in sentences:
        return "Battery"

    if 'temperature' in sentences:
        return "Temperature"
    if 'Temperature' in sentences:
        return "Temperature"

    if 'memory' in sentences:
        return "Memory"
    if 'Memory' in sentences:
        return "Memory"

    if 'audio' in sentences:
        return "Audio"
    if 'Audio' in sentences:
        return "Audio"

    if 'design' in sentences:
        return "Design"
    if 'Design' in sentences:
        return "Design"

    return "Others"

h.loc[:, 'Category'] = h.Mention.apply(check_it)

h.to_csv('C:/Desktop/ResultWithCategory.csv')

I got error on this code and I dont know why the error shows up 我在此代码上有错误,但我不知道为什么会显示错误

This is unicode conversion error, try this... 这是unicode转换错误,请尝试...

h = pd.read_csv('C:/Users/Desktop/Result.csv', encoding = "utf-8") h = pd.read_csv('C:/Users/Desktop/Result.csv',编码=“ utf-8”)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:'utf8'编解码器无法解码位置0中的字节0x80:无效的起始字节 - Error: 'utf8' codec can't decode byte 0x80 in position 0: invalid start byte UnicodeDecodeError:'utf8'编解码器无法解码位置11的字节0x80:无效的起始字节 - UnicodeDecodeError: 'utf8' codec can't decode byte 0x80 in position 11: invalid start byte Python UnicodeDecodeError:'utf8'编解码器无法解码位置74的字节0x80:无效的起始字节 - Python UnicodeDecodeError: 'utf8' codec can't decode byte 0x80 in position 74: invalid start byte Python:UnicodeDecodeError:'utf-8'编解码器无法解码 position 中的字节 0x80 0:无效起始字节 - Python: UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte UnicodeDecodeError:'utf-8'编解码器无法解码位置0的字节0x80:无效的起始字节 - UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte UnicodeDecodeError: 'utf-8' 编解码器无法解码位置 3131 中的字节 0x80:起始字节无效 - UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 3131: invalid start byte 'utf-8' 编解码器无法解码 position 中的字节 0x80 28:起始字节无效 - 'utf-8' codec can't decode byte 0x80 in position 28: invalid start byte 在Windows上使用python错误:UnicodeDecodeError:'utf-8'编解码器无法解码位置110的字节0x80:无效的起始字节 - using python on windows error: UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 110: invalid start byte UnicodeDecodeError:'utf-8'编解码器无法解码位置3131中的字节0x80:我的代码中的无效起始字节 - UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 3131: invalid start byte in my code 'utf-8' 编解码器无法解码 position 中的字节 0x80 3131:无效的起始字节':在读取 xml 文件时 - 'utf-8' codec can't decode byte 0x80 in position 3131: invalid start byte': while reading xml files
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM