我的整个代码是:
import itertools as it
import numpy as np
import scipy
from scipy import special
for q in [29, 37, 53, 61]:
p = int((q-1)/4)
d0 = [2**(4*i) % q for i in range(p)]
d2 = [2**(4*i + 2) % q for i in range(p)]
c2 = list(it.combinations(d0,2))
cd = list(it.combinations(d2,p-2))
s2 = [sum(c2[i]) % q for i in range(len(c2))]
sd = [sum(cd[i]) % q for i in range(len(cd))]
a = [i for i,x in enumerate(s2) if x == 1]
b = [i for i,x in enumerate(sd) if x == 1]
l = [list(c2[i]) for i in a]
l1 = [list(cd[i]) for i in b]
c = [[d0.index(l[i][j]) for j in range(2)] for i in range(len(l))]
d = [[d2.index(l1[i][j]) for j in range(p-2)] for i in range(len(l1))]
cp = [[4*c[i][j] for j in range(2)] for i in range(len(c))]
dp = [[4*d[i][j]+2 for j in range(p-2)] for i in range(len(d))]
dps = [set(x) for x in dp]
dpp = [4*i+2 %q for i in range(p)]
cop_dpp = []
for i in range(len(dp)):
cop_dpp.append(dpp)
cop_dpps = [set(x) for x in cop_dpp]
diff = [cop_dpps[i] - dps[i] for i in range(len(dp))]
diffl = [list(x) for x in diff]
e = []
for i in range(len(cp)):
for o in range(len(cp)):
x = cp[i] + diffl[o]
e.append(x)
f = []
for k in range(1):
for l in range(1):
x = e[k] + e[l]
f.append(x)
print(q,cp)
print(q, diffl)
print(q,e)
print(q,f)
它给出的错误是:
f = []
^
IndentationError: unindent does not match any outer indentation level
我试过在每个地方移动f = []。在代码中的不同位置标记它(以及它所依赖的for循环),但获得相同的错误。写了一段简单的代码:
a = [[1,2,3]]
b = [[3,4,5]]
e = []
for i in range(len(a)):
for o in range(len(b)):
x = a[i] + b[o]
e.append(x)
f = []
for k in range(len(e)):
for l in range(len(e)):
x = e[k] + e[l]
f.append(x)
print(e)
print(f)
运行正常。我已经为每行代码使用了制表符。任何帮助将非常感激。先感谢您!
答案 0 :(得分:1)
在文本编辑器或IDE中找到允许您查看空格的设置 - 这将帮助您查看代码中选项卡和空格之间的区别。正如有人在评论中所说,如果你有混合(例如当文本编辑器中的默认值与你本能地做的不同时会发生),python将无法计算出你的缩进。