Python 新手...Python 3 和 Matplotlib
我想学习Python。我有一门关于 Python 3 的课程。但是,我需要主要使用 matplotlib 和 Numpy,而这些库尚未与 Python 3 兼容。是否值得用 Python 3 来完成该课程,否则会浪费时间学习 Python 3 然后再回到 Python 2.x?
你会怎么办?
I want to learn Python. I have a course to do in Python 3. However, I will need to use mainly the matplotlib and Numpy, and these libraries are not yet compatible with Python 3. Is it worth doing the course in Python 3 or will be a waste of time to learn Python 3 and then came back to Python 2.x?
What would you do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
仅供参考,Matplotlib 现已移植到 Python 3。
FYI, Matplotlib is now ported to Python 3.
学习 Python 3 后,回到 Python 2.x 不会有问题,反之亦然。没有太多差异。 (一些标准库发生了变化, print 是一个函数,所有字符串都是 unicode ——你永远不会注意到其中的大多数)。
实际上,如果您现在学习 Python 3,并找到一份使用 Python 的工作,那么您现在几乎肯定会使用 Python 2.x。 Python 3 尚未得到广泛采用。然而,在不久的将来,Python 3 将被更多地采用,因为许多库正在移植到 Python 3。
如果您需要专门使用 Matplotlib,那么您应该使用 Python 2.7(如果现在使用 Python 3 没有意义,如果您需要的库不适用于它)。但首先学习 Python 3 绝不会让你处于任何劣势,并且可能会让你在大多数人最终做出转变时处于领先地位。
也没有什么可以阻止您同时使用两者(Python 3 用于学习/实验,Python 2.7 用于工作)。
You won't have a problem going back to Python 2.x after learning Python 3, or vice versa. There aren't too many differences. (Some standard library changes, print is a function, all strings are unicode -- you'll never notice most of them).
Realistically, if you learn Python 3 now, and get a job working with Python, you will almost definitely be working with Python 2.x for right now. Python 3 hasn't gained wide adoption yet. However, Python 3 will be more adopted in the near future, as a number of libraries are being ported to Python 3.
If you need to use Matplotlib specifically, then you should use Python 2.7 (no sense in using Python 3 right now if the library you need doesn't work for it). But learning Python 3 first will by no means put you at any disadvantage and may put you ahead of the curve when most people finally make the switch.
There's also nothing stopping you from using both (Python 3 for learning/experimenting, Python 2.7 for work).
“你会怎么办?”
我会将 matplotlib 移植到 Python 3。:-)
但不,Python 3 课程并没有浪费。差异主要在于标准库以及细微的内部差异。
语言本身的主要区别在于,unicode 类型在 Python 3 中称为 str,而
print
是一个函数。差异并没有大到浪费一门课程。"What would you do?"
I would port matplotlib to Python 3. :-)
But no, a course in Python 3 is not wasted. The differences are mainly in the standard library, and in subtle internal differences.
The major differences in the language itself is that the unicode type is called str in Python 3, and that
print
is a function. The differences are not so big that a course is wasted.另一种方法是使用类似 cython 的东西,它允许您生成兼容的本机 python 库(无需使用 2to3 或 3to2 )同时具有 2.x 和 3.x。然而,这是一项工作。不过,您确实可以在不支持这些功能的 python 版本中使用 set 和 dict 理解。
Another way to go is using something like cython which allows you to generate native python libraries that are compatible (without using 2to3 or 3to2) with both 2.x and 3.x. However, it is a bit of work. You do get to use set and dict comprehensions with versions of python that don't support those features though.