? LVector[l/6] +=1 為何報錯?
代碼如下:
for oneRow in range(rowcnt):
for ?oneCol in range(colcnt):
r, g, b = ndarr[oneRow][oneCol]
h, s, v = colorsys.rgb_to_hsv(r/255, g/255, b/255)
h = h * 360
l = self._hsv2L(h, s, v)
LVector[l/6] +=1
lsum ?=sum(LVector)
result = [v * 1.0/lsum for v in LVector]
代碼報錯如下:
?LVector[l/6] +=1
TypeError: list indices must be integers or slices, not float
2018-08-04
也可以寫成LVector[l//6] +=1
2018-03-11
可以改成?LVector[int(l/6)] +=1