Syntax Error In Python Print Statement

岁酱吖の 提交于 2019-12-02 10:16:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!