它在此函数中的SUM变量中工作得很好
def print_direction():
global start_time
stack = []
i = end_pos[0]
j = end_pos[1]
SUM = int(mat[start_pos[0]][start_pos[1]]).data
for m in range(mat_size):
for n in range(mat_size):
print(mat[m][n].kep, end="****")
print()
while i != start_pos[0] or j != start_pos[1]:
SUM += mat[i][j].data
stack.append(mat[i][j].direc)
a = get_key(mat[i][j].direc)
i -= a[0]
j -= a[1]
while stack:
print(stack.pop(), end='-')
if s == 1:
S = "Yes"
else:
S = "No"
print(" count_node: " + str(count_node) + " sum: " + str(SUM))
## Python program to print the data
table = [
["Problem", "Heuristic name", "N", "d/N", "Success (Y/N)", "Time (sec)", "EBF", "avg H value", "Min", "Avg",
"Max"], ["1", "straight line distance", count_node, format(deth / count_node, '.3f'), S,
format(time.time() - start_time, '.3f'), format(EBF / count_node, '.2f'),
format(E_Heuristic / time_act, '.2f'), Min, format(ave / help_ave, '.2f'), Max]]
print(tabulate(table))
print(help_ave)
print(help_ave)
但不是在这个变量中
temp1=int(mat[start_pos[0]][start_pos[1]]).data
发布于 2020-12-12 00:21:45
从您发布的代码来看,正确的解决方案似乎是:
temp1=int(mat[start_pos[0]][start_pos[1]].data)
假设代码中的SUM += mat[i][j].data
这一行按原样工作,则不需要转换为int
https://stackoverflow.com/questions/65260257
复制相似问题