hello ="bonjour"python2.7上的语法错误

tas*_*pai 0 python syntax syntax-error python-2.7

我尝试在python中启动一个基本程序,它是:

#!/usr/bin/python2.7
# -*- coding: utf-8 -*-

hello = "world"
Run Code Online (Sandbox Code Playgroud)

我收到这个错误:

File "toto.py", line 4
  hello = "world"
          ^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

但我确定这是好语法!那我在哪里错了?

谢谢.

DSM*_*DSM 6

如果你查看你的问题标题,你可能会注意到:引号很奇特.如果我使用的是引号“bonjour”而不是"bonjour",那就是你会看到的错误信息:

~/coding$ python2.7 hello.py 
  File "hello.py", line 4
    hello=“bonjour”
          ^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

"改用.

(我知道你的成绩单使得它看起来像你那样使用",但我敢肯定你没有.这是否意味着你正在运行一个不同的代码比你认为你,或者你粘贴错误的代码,或者你的想象引号并没有被粘贴到SO中,我不确定.但这是潜在的问题.)