我正在學習Python中,你可以請幫助我這個代碼 爲伽羅瓦域XOR 代碼錯誤「廉政」對象不是標化的蟒蛇
def generateGF(a,b):
for x in range(a**b-1):
for y in range(a**b-1):
a[x][y] = bin(x)[2:].zfill(3) + bin(y)[2:].zfill(3) # limited for 2^3
for i in range(a**b):
for j in range(a**b):
print(bin(z[i][j]),end=' ')
print("\n")
print (generateGF(2,3))
,我收到此錯誤
python lab5.py :(
Traceback (most recent call last):
File "lab5.py", line 9, in <module>
print (generateGF(2,3))
File "lab5.py", line 4, in generateGF
a[x][y] = bin(x)[2:].zfill(3) + bin(y)[2:].zfill(3) # limited for 2^3
TypeError: 'int' object is not subscriptable
'了'是整數'2',所以你期望'a [x] [y]'是什麼意思? – Barmar
當你得到這樣的錯誤時,拆分子表達式,以便得到更準確的消息。 –
在你的第二個循環中你有'z [i] [j]'。變量'z'在哪裏定義? – Barmar