2
我試圖在基於python3的Crab(一個開源推薦系統)上運行測試。然後發生了錯誤:錯誤:'Numpy.str_'對象沒有'decode'屬性
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/Dennis/anaconda/lib/python3.5/site-packages/scikits/crab/datasets/base.py", line 201, in load_sample_movies
data_songs[u_ix][i_ix] = float(rating)
ValueError: could not convert string to float: "b'3.0'"
我試圖用「解碼()」將字符串轉換,但它不工作:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/Dennis/anaconda/lib/python3.5/site-packages/scikits/crab/datasets/base.py", line 202, in load_sample_movies
rating = rating.decode('utf-8')
AttributeError: 'numpy.str_' object has no attribute 'decode'
任何幫助將不勝感激!
「b'3.0'」是unicode,Py3默認字符串類型。所以它有一個「編碼」,但不是「解碼」。但是,這並沒有得到多餘的報價。 – hpaulj