我在python中有以下功能:
def find_str(s, m):
starting_points = find_starting_points(s,m)
solution = []
for i in range(0, len(starting_points)):
position = starting_points[i]
solution.append([position])
solution = build_solution(position, s, m, solution)
return solution
pass
当我在ipython中运行该文件时,出现以下错误:
55 for i in range(0, len(starting_points)):
56 position = starting_points[i]
---> 57 solution.append([position])
58 solution = build_solution(position, s, m, solution)
59 return solution
AttributeError: 'NoneType' object has no attribute 'append'
为什么我会收到错误?
答案 0 :(得分:8)
您的build_solution
函数在某个时刻返回None
。由于您将solution
设置为此函数的返回值,因此您将其设置为无。
除非您显示build_solution
的代码,否则我无法更具体。