简体   繁体   English

语法错误:语法无效?

[英]SyntaxError: invalid syntax?

Good afternoon,下午好,

I am developing a script in python and while I am trying to compile it from the terminator/terminal i always get this error, but I cannot understand where is the syntax error?我正在用 python 开发一个脚本,当我试图从终止符/终端编译它时,我总是收到这个错误,但我不明白语法错误在哪里?

File "_case1.py", line 128文件“_case1.py”,第 128 行

print ('########################')
    ^

SyntaxError: invalid syntax语法错误:无效语法

Then I just change the position of the sentence and what I get is..然后我只是改变句子的位置,我得到的是..

print '########################'
    ^

SyntaxError: invalid syntax语法错误:无效语法

What is the problem?问题是什么?

Check the code before the print line for errors.检查print行之前的代码是否有错误。 This can be caused by an error in a previous line;这可能是由前一行中的错误引起的; for example:例如:

def x():
    y = [
    print "hello"
x()

This produces the following error:这会产生以下错误:

  File "E:\Python\test.py", line 14
    print "hello"
        ^
SyntaxError: invalid syntax

When clearly the error is in the line before it, y = [ .当错误明显在它之前的行中时, y = [ It's tough to debug without more code, but if you have some brackets missing before the print line or something similar it can cause such an error.没有更多代码就很难调试,但是如果在打印行之前缺少一些括号或类似的东西,它可能会导致这样的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM