我是一个蟒蛇新手,我仍然习惯了这种语言。 Python给我一个语法错误:
File "align.py", line 274
print dic1 = return (traceback_global(M_direction, Ix_direction, Iy_direction, tempList[0], A_scoreDic, B_scoreDic, dic) + dic)
^
SyntaxError: invalid syntax
这些是错误所指的行。有人可以告诉我有什么问题吗?
print dic1 = return (traceback_global(M_direction, Ix_direction, Iy_direction, tempList[0], A_scoreDic, B_scoreDic, dic) + dic) ##checks direction 1
print dic2 = return (traceback_global(M_direction, Ix_direction, Iy_direction, tempList[1], A_scoreDic, B_scoreDic, dic) + dic) ##checks direction 2
print dic3 = return (traceback_global(M_direction, Ix_direction, Iy_direction, tempList[2], A_scoreDic, B_scoreDic, dic) + dic)
这是此代码的方法签名:
def trackback_global(M_direction, Ix_direction, Iy_direction, curr_tup, A_scoreDic, B_scoreDic, dic)
答案 0 :(得分:2)
您试图将3个单独的陈述混合在一起:
print xxx
)dic1 = xxx
)return xxx
)您只能在一行中拥有三个中的一个。首先找出你希望你的程序做什么,然后选择合适的。
答案 1 :(得分:1)
您想要对该代码做什么并不是很清楚。
无论如何,我认为通过这种方式你可以得到你想要的东西:
dic1 = traceback_global(M_direction, Ix_direction, Iy_direction, tempList[0], A_scoreDic, B_scoreDic, dic) + dic
dic2 = traceback_global(M_direction, Ix_direction, Iy_direction, tempList[1], A_scoreDic, B_scoreDic, dic) + dic
dic3 = traceback_global(M_direction, Ix_direction, Iy_direction, tempList[2], A_scoreDic, B_scoreDic, dic) + dic
print dic1
print dic2
print dic3
将在traceback_global
函数中使用return语句,将函数返回的值赋给变量dic1,dic2和dic3。