2016-08-29 126 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

哦!男人謝謝您的幫助 –