2017-05-04 61 views
-2

这不是重复的,因为我使用python 2.7.6,而不是3为什么是无效的语法错误打印“%s没有在%s存在%s”的<----%(

我使用的是从V8源回购the script,它给我的错误:

D:\v8\source\v8\tools\dev>v8gen.py x64.release 
    File "D:\v8\source\v8\tools\dev\v8gen.py", line 147 
    print '%s does not exist in %s for %s' % (
             ^
SyntaxError: invalid syntax 

文件本身应该罚款,因为它的工作在其他环境中,可能是Linux,但我跑该脚本来自Windows 10本地shell(cmd)。

我不熟悉python,有人可以提出什么可能是错的吗?

+1

我们就需要看到更多的代码。你的打印参数是否有尾括号?你试图打印的确切值是3? – NuclearPeon

+2

[“Good Code”上的SyntaxError](http://stackoverflow.com/documentation/python/9300/commonwealth-exceptions/30292/syntax-error-on-good-code#t=201705041812501801264) – TemporalWolf

+0

@NuclearPeon,I'已经链接到实际的文件内容,[这里又是](https://chromium.googlesource.com/v8/v8.git/+/master/tools/dev/v8gen.py#147) –

回答

2

我想你使用的是Python 3.x,而这段代码是用Python 2.x编写的。

尝试在Python的正确版本运行它,或将其更改为:

print ('%s does not exist in %s for %s' % (
     self._options.builder, CONFIG, self._options.master)) 
+0

的位置非常好。事实并非如此。在python3中,如果在没有括号的情况下调用print,则会引发'SyntaxError:在调用'print'时缺少小括号' – RafaelC

+1

@RafaelCardoso之后添加。在Python 3的早期版本中,它只是说SyntaxError。 – ayhan

+0

亲自试一试。它首先引发这个错误:) @RafaelCardoso –

相关问题