inputfile = 'data3.csv'
f = open(inputfile, 'r')
data = f.read()
#data = data.decode('utf-8')
#data = data.decode('utf-8')
def find_differential_expression(data, N=100, max=100000, min=2): #N is most commonly found genes hits, minimum is the number of repeats for each gene
datasplit = data.split(",")
from collections import Counter
datacount = Counter(datasplit)
datacount = datacount.most_common(N)
datacount = [x for x in datacount if x[0] not in ['', '\n','-','- /','- / Blank_Space']]
datacount = [x for x in datacount if not x[0].startswith("- / ")]
datacount = [x for x in datacount if x[1] > min]
datacount = [x for x in datacount if x[1] < max]
return datacount
我正在使用python 3.5并在Anaconda中遇到这种错误:
string.decode('utf-8')
不起作用。我怎样才能解决这个问题?错误消息如下。
Traceback (most recent call last):
File "<ipython-input-1-79d5084f03e2>", line 6, in <module>
data = f.read()
File "//anaconda/lib/python3.5/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8e in position 16: ordinal not in range(128)