打印在Python 3.3中不起作用?

西伯斯赌博

我正在Visual Studio Professional 2013 RC中运行Python。我已经安装Python 3.3附带的Visual Studio的Python工具

我只是在做一个非常简单的打印语句,但是它报告语法错误。

print 'aaa'

另外,输入后Enter,口译员拒绝打印aaa屏幕截图如下:

在此处输入图片说明

来自解释器的错误消息

>>> print '1
... '
... 
Traceback (most recent call last):
  File "C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.0\visualstudio_py_repl.py", line 627, in run_one_command
    self.execute_item()
  File "C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.0\visualstudio_py_repl.py", line 601, in execute_code_work_item
    code = compile(self.current_code, '<stdin>', 'single', self.code_flags)
  File "<stdin>", line 1
    print '1
           ^
SyntaxError: EOL while scanning string literal
>>> a=1
>>> print a
Traceback (most recent call last):
  File "C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.0\visualstudio_py_repl.py", line 627, in run_one_command
    self.execute_item()
  File "C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.0\visualstudio_py_repl.py", line 601, in execute_code_work_item
    code = compile(self.current_code, '<stdin>', 'single', self.code_flags)
  File "<stdin>", line 1
    print a
          ^
SyntaxError: invalid syntax
>>> 

我曾经玩过Python 2.7。为什么在3.3中如此?

特里

print不再是Python 3中的语句,而是函数 print(),因此正确的语法是:

print('aaa')

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

For 循环在 python 3 中不起作用

Python计划模块在Python 3中不起作用

Python dis 模块在 Python 3 中不起作用

unicode 方法在 Python3 中不起作用

日志在 Python 3 中的 Flask 下不起作用

Python 3中的相对导入不起作用

为什么相对导入在Python 3中不起作用?

HyperVolume函数在Python 3中不起作用

TreeView在Python Gtk3中不起作用

python3-cd在反向shell中不起作用

导入后,模块who在Python 3中也不起作用

Python3请求-不起作用

python 3导入不起作用

python 3 suds缓存不起作用

pwntools Python模块在python2中不起作用,但在python3中起作用

PYTHON_TARGETS中的python3_5在Gentoo中不起作用?

在python2中可以,但是在python3中不起作用

config.from_object在Python 3中的Flask中不起作用

在其他函数中声明的变量在主python 3中不起作用?

Python 3 帮助功能中的西里尔字母在 Powershell Windows 10 中不起作用

在Python 3中比较字典中的值不起作用?

Python 3.X Pandas中的简单IF语句不起作用

为什么我的reverse()方法在python 3中不起作用?

为什么“请求”模块超时在python3中不起作用?

ipython3在python3.7的终端中不起作用

Python 3:从文件中读取文本时,Regex不起作用

为什么我的日志记录在Python 3中不起作用?

Python3 Django的ManyToMany关系中的.add()函数不起作用

urllib.request.urlopen(url) 在 python 3 中不起作用

requests.request 在 Mac 上的 Python 3 中不起作用