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

前端 未结 8 1349
天命终不由人
天命终不由人 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:27

    I could also just add that I knew everything about the syntax change between Python2.7 and Python3, and my code was correctly written as print("string") and even print(f"string")...

    But after some time of debugging I realized that my bash script was calling python like:

    python file_name.py

    which had the effect of calling my python script by default using python2.7 which gave the error. So I changed my bash script to:

    python3 file_name.py

    which of coarse uses python3 to run the script which fixed the error.

提交回复
热议问题