最近开始在windows上学习python。我很困惑,因为它显示我在 VS 工具中用于 python 和 Iron Python 控制台的输出的方式。以及 PyScripter 和 IronPython 中的类似区别。
打印命令在 IronPython 控制台和 Visual Studio 中的 Python 3.2 Interactive 中的工作方式不同。
print("Hello") # works perfectly inside visual studio
Hello
print "Hello" # gives error when running ctrl+F5
Invalid Syntax
print "Hello" # works great inside IronPython console
Hello
我注意到的另一件事是,在 PyScripter for windows 中,以下代码没有产生任何结果
range(6)
#nothing happens in PyScripter
range(6) #inside IronPython console works fine
[0,1,2,3,4,5]
知道这里发生了什么吗?
更新:
在 Windows 的 IronPython 控制台中运行以下内容时
>>>import sys
>>>sys.version
'2.7.1 <IronPython 2.7.1 <2.7.0.40) on .NET 4.0.30319.239)'
PyScripter 和 VSTS for Python 中的行为相同 主窗口不产生任何输出(知道吗?运行 PyScripter 2.4.3)并且下面的解释器产生了
'3.2.2 (default, sep 4 2011, 09:51:08) [....]'
请您参考如下方法:
IronPython 仍然是 2.x,其中 print 是一个语句,range() 返回一个列表。这两个changed with 3.x .
