问题
I am trying to figure out why I am receiving the following syntax error on my Python print statement in Eclipse:
print(md5_to_hex(md5(message)),' <= "',message.decode('ascii'),'"', sep='')
^
SyntaxError: invalid syntax
回答1:
from __future__ import print_function
Print isn't a function yet, import the future version of print to get it to behave this way.
回答2:
In python-2.x
print(whatever)
is roughly* equivalent to
print whatever
In your case, whatever
is
md5_to_hex(md5(message)),' <= "',message.decode('ascii'),'"', sep=''
which is not a valid expression.
* (That's not true if (whatever)
is a tuple)
来源:https://stackoverflow.com/questions/14071479/syntax-error-in-python-print-statement