Python 3.X或Python 2.X

时间:2021-09-20 02:35:18

What's the ideal Python version for a beginner to start learning Python? I need to recommend some newbies a programming language to learn and I chose Python. I'm still not sure which version.

什么是初学者开始学习Python的理想Python版本?我需要推荐一些新手学习编程语言,我选择了Python。我还不确定哪个版本。

5 个解决方案

#1


9  

It depends what you're going to do with it.

这取决于你将要做什么。

Unicode handling has vastly improved in Python 3. So if you intend to use this for building web pages or some such, Python 3 might be the obvious choice.

Python 3中的Unicode处理得到了极大的改进。因此,如果您打算使用它来构建网页或其他类似的东西,Python 3可能是显而易见的选择。

On the other hand, many libraries and frameworks still only support Python 2. For example, the numerical processing library numpy, and the web framework Django both only work on Python 2. So if you intend to use any of those, stick with Python 2.

另一方面,许多库和框架仍然只支持Python 2.例如,数字处理库numpy和web框架Django都只适用于Python 2.所以如果你打算使用其中任何一个,坚持使用Python 2 。

Either way, the differences aren't huge to begin with. I'd say Python 3 is a little easier to pick up (due to its string handling), but that is a good reason to learn Python 2 first. That way, if you run into a piece of Python 2 code (and you will), you'll know what is going on.

无论哪种方式,差异都不是很大的开始。我会说Python 3更易于获取(由于它的字符串处理),但这是首先学习Python 2的一个很好的理由。这样,如果你遇到一段Python 2代码(你会),你就会知道发生了什么。

#2


3  

Adoption of Python3 has been held up by a few critical 3rd party packages. numpy is a good example of a package that has just barely started working on Python3. Quite a few other packages depend on numpy, so they will hopefully be supporting Python3 very shortly too.

一些关键的第三方软件包阻止了Python3的采用。 numpy是一个刚刚开始使用Python3的软件包的一个很好的例子。相当多的其他软件包依赖于numpy,所以他们很快就会支持Python3。

Most of the time it's possible to write code that is compatible with 2.6/2.7/3.1 by using __future__ imports. So learning one does not mean you are not learning the other.

大多数情况下,使用__future__导入编写与2.6 / 2.7 / 3.1兼容的代码是可能的。所以学习一个并不意味着你没有学习另一个。

#3


1  

My vote is for 3.1

我的投票是3.1

My reasoning is simple and selfish. The more new python programmers that only use 3.1 there are, the more likely it is that one of them is going to decide that they need some library from 2.6 and port it to 3.1 (learning 2.6 in the process I might add).

我的推理简单而自私。那些只使用3.1的新python程序员越多,他们中的一个就越有可能决定他们需要2.6中的某个库并将其移植到3.1(在我可能添加的过程中学习2.6)。

After this happens, I can start using 3.1: it looks really cool.

发生这种情况后,我可以开始使用3.1:它看起来很酷。

#4


0  

I would suggest Python 2.6; I know it's old, but it's not only the current standard, and there is way more documentation and libraries available for it.

我会建议Python 2.6;我知道它已经过时了,但它不仅是当前的标准,还有更多的文档和库可用。

#5


0  

I'll throw my experience into the works:

我将把我的经验投入到工作中:

Right now you should be using 2.6. Switch to 2.7 when 2.7.1 comes out. Switch to 3.1/2 when all the libraries you want are fully supported and stable there.

现在你应该使用2.6。当2.7.1出现时切换到2.7。当你想要的所有库都完全支持并在那里稳定时,切换到3.1 / 2。

#1


9  

It depends what you're going to do with it.

这取决于你将要做什么。

Unicode handling has vastly improved in Python 3. So if you intend to use this for building web pages or some such, Python 3 might be the obvious choice.

Python 3中的Unicode处理得到了极大的改进。因此,如果您打算使用它来构建网页或其他类似的东西,Python 3可能是显而易见的选择。

On the other hand, many libraries and frameworks still only support Python 2. For example, the numerical processing library numpy, and the web framework Django both only work on Python 2. So if you intend to use any of those, stick with Python 2.

另一方面,许多库和框架仍然只支持Python 2.例如,数字处理库numpy和web框架Django都只适用于Python 2.所以如果你打算使用其中任何一个,坚持使用Python 2 。

Either way, the differences aren't huge to begin with. I'd say Python 3 is a little easier to pick up (due to its string handling), but that is a good reason to learn Python 2 first. That way, if you run into a piece of Python 2 code (and you will), you'll know what is going on.

无论哪种方式,差异都不是很大的开始。我会说Python 3更易于获取(由于它的字符串处理),但这是首先学习Python 2的一个很好的理由。这样,如果你遇到一段Python 2代码(你会),你就会知道发生了什么。

#2


3  

Adoption of Python3 has been held up by a few critical 3rd party packages. numpy is a good example of a package that has just barely started working on Python3. Quite a few other packages depend on numpy, so they will hopefully be supporting Python3 very shortly too.

一些关键的第三方软件包阻止了Python3的采用。 numpy是一个刚刚开始使用Python3的软件包的一个很好的例子。相当多的其他软件包依赖于numpy,所以他们很快就会支持Python3。

Most of the time it's possible to write code that is compatible with 2.6/2.7/3.1 by using __future__ imports. So learning one does not mean you are not learning the other.

大多数情况下,使用__future__导入编写与2.6 / 2.7 / 3.1兼容的代码是可能的。所以学习一个并不意味着你没有学习另一个。

#3


1  

My vote is for 3.1

我的投票是3.1

My reasoning is simple and selfish. The more new python programmers that only use 3.1 there are, the more likely it is that one of them is going to decide that they need some library from 2.6 and port it to 3.1 (learning 2.6 in the process I might add).

我的推理简单而自私。那些只使用3.1的新python程序员越多,他们中的一个就越有可能决定他们需要2.6中的某个库并将其移植到3.1(在我可能添加的过程中学习2.6)。

After this happens, I can start using 3.1: it looks really cool.

发生这种情况后,我可以开始使用3.1:它看起来很酷。

#4


0  

I would suggest Python 2.6; I know it's old, but it's not only the current standard, and there is way more documentation and libraries available for it.

我会建议Python 2.6;我知道它已经过时了,但它不仅是当前的标准,还有更多的文档和库可用。

#5


0  

I'll throw my experience into the works:

我将把我的经验投入到工作中:

Right now you should be using 2.6. Switch to 2.7 when 2.7.1 comes out. Switch to 3.1/2 when all the libraries you want are fully supported and stable there.

现在你应该使用2.6。当2.7.1出现时切换到2.7。当你想要的所有库都完全支持并在那里稳定时,切换到3.1 / 2。