我正在设置一个像Matlab这样的环境,所以我下载了最新版本的python(x,y)以及随附的所有模块并下载了python 3.4.1。 python(x,y)是不是运行最新版本的python?我注意到因为python(x,y)shell没有自动计算浮点数的数学运算,我读到的是python 2.x和3.x之间的差异。我是否只需要等待(x,y)的新版本或者我在这里遗漏了什么?
您可以使Python 2的行为与Python 3 w.r.t相同。用以下命令划分;
from __future__ import division
来自__future__
的进口应该在文件的顶部。可能有一种方法可以自动加载这个表达式(我知道它可以在IPython中使用),但我不熟悉python(x,y)。
有关Python的更多信息,可以通过python.org获取这些教程。推荐使用最新版本的Python3。
由于您处于过渡过程中,请查看SciPy(http://www.scipy.org)和Sage(http://www.sagemath.org/tour.html)。这些可能更适合您需要解决的问题。
如果您在终端上进行了大量的互动工作,请查看ipython(http://ipython.org)。
关于除法运算符在Python2中默认为整数除法,但在Python3中只是正常除法。您可以在启动解释器时使用-Q标志来更改此设置。 (Do:python --help)例如:
$ python2.7 -Qnew
Python 2.7.6 (default, Nov 18 2013, 15:12:51)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1/2
0.5
>>>
$ python2.7
Python 2.7.6 (default, Nov 18 2013, 15:12:51)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1/2
0
>>>
$ python3.4
Python 3.4.1 (default, May 21 2014, 01:39:38)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1/2
0.5
>>>
感觉原始问题是关于python(x,y)-distribution和Python 3的重要问题,我的(长)答案是:
我使用这种发行多年并喜欢它。但对我来说似乎没有计划升级它以包含python 3环境。
这些天我会推荐Anaconda分销/项目(https://www.anaconda.com/)。非常类似于python(x,y)-idea但更好地维护和支持“最新的一切”。