What does “SyntaxError: Missing parentheses in call to 'print'” mean in Python?

前端 未结 8 1313
天命终不由人
天命终不由人 2020-11-21 09:02

When I try to use a print statement in Python, it gives me this error:

>>> print \"Hello, World!\"
  File \"\", line 1
            


        
8条回答
  •  情深已故
    2020-11-21 09:40

    There is a change in syntax from Python 2 to Python 3. In Python 2,

    print "Hello, World!" 
    

    will work but in Python 3, use parentheses as

    print("Hello, World!")
    

    This is equivalent syntax to Scala and near to Java.

提交回复
热议问题