2016-08-29 172 views
-1

我在最终变量中收到无效的语法错误。我看不出什么问题,我认为我的缩进是正确的,可以告诉我我做错了什么?我试图做一个简单的python xor程序。Python-语法错误

msg='To use this decimal to binary converter tool, you should type a decimal value like 308 into the left field below, and then hit the Convert button. This way you can convert up to 19 decimal characters (max. value of 9223372036854775807) to binary value.' 
key='ab' 

encrypt=[] 
decrypt=[] 
count=0 

for i in msg: 
    if count>=len(key): 
      count=0 

    encrypt.append(ord(i)^ord(key[count])) 

    count+=1 

count=0 
print(encrypt) 

for i in encrypt: 

    if count>=len(key): 
      count=0 

    count+=1  
    decrypt.append(i^ord(key[count]) 

final=''.join(chr(e) for e in decrypt) 
print(final)     
+1

不是张贴的截图,发布您的代码在这里 – user7

+0

好吧,我改变了它 –

回答

1

当你在为D on't意义算你括号的地方看到可疑错误信息!

在你的情况下,你调用ord功能时错过了一个右括号:

decrypt.append(i^ord(key[count])) 
+0

哦!男人谢谢您的帮助 –