我有一个CSV文件,当我尝试在Python 2.7中读取它时,会出现以下错误。
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 10: ordinal not in range(128)
到目前为止,这是我的代码,
with open('train.csv', 'rb') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
text=(row['Descript'])
emotion = (row['Category'])
我从此网站找到了许多解决方案,例如How to fix: "UnicodeDecodeError: 'ascii' codec can't decode byte",UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 1 但他们无法解决我的错误。任何人都可以帮助我。