这里是一个类:的Python - 类型错误:类型的 '...' 对象没有LEN()
class CoordinateRow(object):
def __init__(self):
self.coordinate_row = []
def add(self, input):
self.coordinate_row.append(input)
def weave(self, other):
result = CoordinateRow()
length = len(self.coordinate_row)
for i in range(min(length, len(other))):
result.add(self.coordinate_row[i])
result.add(other.coordinate_row[i])
return result
这是我计划的一部分:
def verwerk_regel(regel):
cr = CoordinateRow()
coordinaten = regel.split()
for coordinaat in coordinaten:
verwerkt_coordinaat = verwerk_coordinaat(coordinaat)
cr.add(verwerkt_coordinaat)
cr2 = CoordinateRow()
cr12 = cr.weave(cr2)
print cr12
def verwerk_coordinaat(coordinaat):
coordinaat = coordinaat.split(",")
x = coordinaat[0]
y = coordinaat[1]
nieuw_coordinaat = Coordinate(x)
adjusted_x = nieuw_coordinaat.pas_x_aan()
return str(adjusted_x) + ',' + str(y)
但我米在 “CR12 = cr.weave(CR 2)” 歌厅一个错误:在范围
对于i(分钟(长度,LEN(其他))):
类型错误:类型的对象 'CoordinateRow' 没有升en()
不知道你的问题是什么。你在'CoordinateRow'的实例上调用'len',但该类没有定义'__len__'函数。 – 2014-11-23 13:57:50