我有以下要运行的python脚本。但是,每当我尝试运行脚本时,它都会在我的命令提示符下不断显示错误消息。错误信息:
File "xor.py", line 9
File = open(sys.argv[1], 'rb').read<>
SyntaxError: Invalid Syntax
以下是我在cmd中执行的命令:
python xor.py sample_output.txt 'what would the secret be?'
以下是脚本:
# xor.py
import sys
from itertools import cycle
file = open(sys.argv[1], 'rb').read()
string = sys.argv[2]
sys.stdout.write(''.join(chr(ord(x)^ord(y)) for (x,y) in zip(file, cycle(string))))