TypeError: can't multiply sequence by non-int of type 'float'. Python 3
TypeError: can't multiply sequence by non-int of type 'float'. Python 3
first = int(list1[0] + list1[1])
a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23 = map(float, list1)
if first == 11:
c = con.execute("SELECT Centroid FROM Centroid WHERE ItemID = 1")
centroid = c.fetchone()
AA = (min(a1, a2) * centroid) + (pow(a3,2))
BB = (min(a1, a2) + a3)
WA = AA/BB
print (WA)
以上是我的代码。我现在的问题是出现错误:
TypeError: can't multiply sequence by non-int of type 'float'
我使用的变量(a1,a2,a3,centriod)是一种浮点型。
您需要从元组中获取质心的第一个元素用作值,因为 type(centroid) is tuple
是 True
。使用:
centroid = c.fetchone()[0]
first = int(list1[0] + list1[1])
a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23 = map(float, list1)
if first == 11:
c = con.execute("SELECT Centroid FROM Centroid WHERE ItemID = 1")
centroid = c.fetchone()
AA = (min(a1, a2) * centroid) + (pow(a3,2))
BB = (min(a1, a2) + a3)
WA = AA/BB
print (WA)
以上是我的代码。我现在的问题是出现错误:
TypeError: can't multiply sequence by non-int of type 'float'
我使用的变量(a1,a2,a3,centriod)是一种浮点型。
您需要从元组中获取质心的第一个元素用作值,因为 type(centroid) is tuple
是 True
。使用:
centroid = c.fetchone()[0]