Rodeo UnicodeDecodeError:'ascii'编解码器无法解码位置0的字节0xef:序数不在范围内(128) [英] Rodeo UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)

查看:198
本文介绍了Rodeo UnicodeDecodeError:'ascii'编解码器无法解码位置0的字节0xef:序数不在范围内(128)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用Python3.我正在尝试使用Rodeo IDE打开一个csv文件

I have just started using Python3. I am trying to open a csv file using Rodeo IDE

fp = open('Proteomics_Data.csv') # open file on read mode
lines = fp.read().split("\n") # create a list containing all lines

我收到一个错误,将其粘贴在下面.

I am getting an error I paste it below.

UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)
---------------------------------------------------------------------------
UnicodeDecodeError                        Traceback (most recent call last)
<ipython-input-347-aebf19dd596a> in <module>()
----> 1 lines = fp.read().split("\n")
/Users/alessandro/anaconda/lib/python3.6/encodings/ascii.py in decode(self, input, final)
     24 class IncrementalDecoder(codecs.IncrementalDecoder):
     25     def decode(self, input, final=False):
---> 26         return codecs.ascii_decode(input, self.errors)[0]
     27 
     28 class StreamWriter(Codec,codecs.StreamWriter):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)

到目前为止,我发现终端没有设置为UTF-8,但是显然Python 3不需要UTF-8.我不确定这是否可能与IDE有关吗?

What I have found so far is the terminal not being set to UTF-8, but apparently Python 3 does not need UTF-8. I am not sure tif this could be a problem related to the IDE?

推荐答案

尝试在open函数调用中指定编码.

Try specifying the encoding in the open function call.

fp = open('Proteomics_Data.csv', encoding='utf-8')

这篇关于Rodeo UnicodeDecodeError:'ascii'编解码器无法解码位置0的字节0xef:序数不在范围内(128)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆