首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >“in”对象在我的AI项目中不可订阅

“in”对象在我的AI项目中不可订阅
EN

Stack Overflow用户
提问于 2020-12-12 08:12:11
回答 1查看 47关注 0票数 0

它在此函数中的SUM变量中工作得很好

代码语言:javascript
复制
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)

但不是在这个变量中

代码语言:javascript
复制
temp1=int(mat[start_pos[0]][start_pos[1]]).data
EN

回答 1

Stack Overflow用户

发布于 2020-12-12 08:21:45

从您发布的代码来看,正确的解决方案似乎是:

代码语言:javascript
复制
temp1=int(mat[start_pos[0]][start_pos[1]].data)

假设代码中的SUM += mat[i][j].data这一行按原样工作,则不需要转换为int

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65260257

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档