感謝您的幫助!我快到了! 我有一組數據,我正在嘗試繪製它,現在只是針對順序整數,後來一旦我有這個工作,對時間。ValueError:無法將字符串轉換爲浮點數:(大字符串)
for a in Data['result'][:1]: #only print the first result in the list
#print a['value']
Data_clean = a['value'].replace('0,','0.')
Data_list = Data_clean.split(',')
T2 = [map(float, x) for x in Data_list] #turn string into integer so that it
#can be graphed
print T2
但出現以下錯誤
T2 = [map(float, x) for x in Data_list]
ValueError: could not convert string to float:
DATA_LIST看起來像這樣
[u'-0.04149', u'-0.03866', u'-0.02914', u'-0.02319', u'-0.02027', u'-0.00234', u'0.00564', u'0.01269', u'0.02852', u'0.04648', u'0.05709', u'0.06261', u'0.07325', u'0.08223', u'0.08665']
ps,這只是數據的一個小竅門,還有更多的方法可以完成。 –
您的格式設置已關閉嗎? 「T2 = ...」和「print T2」是否應該在for循環中? –
您是否需要將字符串轉換爲整數或浮點在'T2 = [map(float,x)for Data_list]'? –