Python 3简介

Python is a high-level, interpreted scripting language developed in the late 1980s by Guido van Rossum at the National Research Institute for Mathematics and Computer Science in the Netherlands. The initial version was published at the alt.sources newsgroup in 1991, and version 1.0 was released in 1994.

Python是由荷兰国家数学和计算机科学研究院的Guido van Rossum于1980年代后期开发的一种高级,解释性脚本语言。 初始版本于1991年在alt.sources 新闻组中发布,而1.0版于1994年发布。

Python 2.0 was released in 2000, and the 2.x versions were the prevalent releases until December 2008. At that time, the development team made the decision to release version 3.0, which contained a few relatively small but significant changes that were not backward compatible with the 2.x versions. Python 2 and 3 are very similar, and some features of Python 3 have been backported to Python 2. But in general, they remain not quite compatible.

Python 2.0于2000年发布,而2.x版本是直到2008年12月为止的普遍版本。当时,开发团队决定发布版本3.0,该版本包含一些相对较小但重要的更改,这些更改不向后兼容2.x版本。 Python 2和3非常相似,并且Python 3的某些功能已向后移植到Python2。但是,总的来说,它们仍然不太兼容。

Both Python 2 and 3 have continued to be maintained and developed, with periodic release updates for both. As of this writing, the most recent versions available are 2.7.13 and 3.6.0. However, an official End Of Life date of January 1, 2020 has been established for Python 2, after which time it will no longer be maintained. If you are a newcomer to Python, it is recommended that you focus on Python 3, as this tutorial will do.

Python 2和3都将继续得到维护和开发,并且会定期对其进行更新。 在撰写本文时,可用的最新版本是2.7.13和3.6.0。 但是,Python 2的正式停产日期为2020年1月1日 ,此后将不再维护。 如果您是Python的新手,建议您专注于Python 3,就像本教程一样。

Python is still maintained by a core development team at the Institute, and Guido is still in charge, having been given the title of BDFL (Benevolent Dictator For Life) by the Python community. The name Python, by the way, derives not from the snake, but from the British comedy troupe Monty Python’s Flying Circus, of which Guido was, and presumably still is, a fan. It is common to find references to Monty Python sketches and movies scattered throughout the Python documentation.

Python仍由该研究所的核心开发团队维护,而Guido仍然由Python社区授予BDFL(终身仁慈的独裁者)头衔。 顺便说一句,Python的名称不是源自蛇,而是源自英国喜剧团Monty Python的《飞天马戏团 》,Guido一直是并且可能仍然是粉丝。 通常会找到散布在整个Python文档中的Monty Python草图和电影的引用。

为什么选择Python? (Why Choose Python?)

If you’re going to write programs, there are literally dozens of commonly used languages to choose from. Why choose Python? Here are some of the features that make Python an appealing choice.

如果您要编写程序,则实际上有数十种常用语言可供选择。 为什么选择Python? 以下是一些使Python成为有吸引力的选择的功能。

Python很流行 (Python is Popular)

Python has been growing in popularity over the last few years. The 2018 Stack Overflow Developer Survey ranked Python as the 7th most popular and the number one most wanted technology of the year. World-class software development countries around the globe use Python every single day.

在过去的几年中,Python越来越流行。 在2018年Stack Overflow开发人员调查中,Python成为年度最受欢迎的第七大技术和第一大最受欢迎的技术。 世界各地的世界一流软件开发国家每天都在使用Python。

According to research by Dice Python is also one of the hottest skills to have and the most popular programming language in the world based on the Popularity of Programming Language Index.

根据Dice的研究,基于编程语言索引流行度, Python也是最热门的技能之一,也是世界上最受欢迎的编程语言

Due to the popularity and widespread use of Python as a programming language, Python developers are sought after and paid well. If you’d like to dig deeper into Python salary statistics and job opportunities, you can do so here.

由于Python作为编程语言的流行和广泛使用,Python开发人员受到追捧并获得了丰厚的报酬。 如果您想更深入地了解Python的薪资统计和工作机会,可以在这里进行

解释了Python (Python is Interpreted)

Many languages are compiled, meaning the source code you create needs to be translated into machine code, the language of your computer’s processor, before it can be run. Programs written in an interpreted language are passed straight to an interpreter that runs them directly.

编译了许多语言,这意味着您创建的源代码需要先转换为机器代码,即计算机处理器的语言,然后才能运行。 用解释语言编写的程序直接传递给直接运行它们的解释器。

This makes for a quicker development cycle because you just type in your code and run it, without the intermediate compilation step.

这使开发周期更快,因为您只需键入代码并运行它,而无需中间编译步骤。

One potential downside to interpreted languages is execution speed. Programs that are compiled into the native language of the computer processor tend to run more quickly than interpreted programs. For some applications that are particularly computationally intensive, like graphics processing or intense number crunching, this can be limiting.

解释语言的潜在缺点之一是执行速度。 编译成计算机处理器本地语言的程序往往比解释程序运行得更快。 对于某些计算量特别大的应用程序,例如图形处理或大量数字运算,这可能会受到限制。

In practice, however, for most programs, the difference in execution speed is measured in milliseconds, or seconds at most, and not appreciably noticeable to a human user. The expediency of coding in an interpreted language is typically worth it for most applications.

但是,实际上,对于大多数程序,执行速度的差异以毫秒或至多秒为单位,对于人类用户而言并不明显。 对于大多数应用程序而言,使用解释语言进行编码通常很值得。

Further reading: See this Wikipedia page to read more about the differences between interpreted and compiled languages.

进一步阅读:请参阅此Wikipedia页面,以了解有关解释语言和编译语言之间差异的更多信息。

Python是免费的 (Python is Free)

The Python interpreter is developed under an OSI-approved open-source license, making it free to install, use, and distribute, even for commercial purposes.

Python解释器是根据OSI批准的开放源代码许可开发的,即使是出于商业目的,也可以免费安装,使用和分发。

A version of the interpreter is available for virtually any platform there is, including all flavors of Unix, Windows, macOS, smartphones and tablets, and probably anything else you ever heard of. A version even exists for the half dozen people remaining who use OS/2.

几乎所有平台都可以使用该解释器的版本,包括Unix,Windows,macOS,智能手机和平板电脑的所有版本,以及您可能听说过的任何其他版本。 甚至还为剩下一半的使用OS / 2的人提供了一个版本。

Python是可移植的 (Python is Portable)

Because Python code is interpreted and not compiled into native machine instructions, code written for one platform will work on any other platform that has the Python interpreter installed. (This is true of any interpreted language, not just Python.)

由于Python代码是经过解释的,并且不会编译为本机指令,因此为一个平台编写的代码将在安装了Python解释器的任何其他平台上运行。 (这适用于所有解释语言,而不仅仅是Python。)

Python很简单 (Python is Simple)

As programming languages go, Python is relatively uncluttered, and the developers have deliberately kept it that way.

随着编程语言的发展,Python相对比较整洁,开发人员故意将其保留为这种方式。

A rough estimate of the complexity of a language can be gleaned from the number of keywords or reserved words in the language. These are words that are reserved for special meaning by the compiler or interpreter because they designate specific built-in functionality of the language.

可以从该语言中关键字或保留字的数量中粗略估计一种语言的复杂性。 这些是保留给编译器或解释器特殊含义的单词,因为它们指定了语言的特定内置功能。

Python 3 has 33 keywords, and Python 2 has 31. By contrast, C++ has 62, Java has 53, and Visual Basic has more than 120, though these latter examples probably vary somewhat by implementation or dialect.

Python 3有33个关键字,Python 2有31个关键字。相比之下,C ++有62个关键字,Java有53个,Visual Basic有120个以上,尽管后面的示例可能因实现或方言而有所不同。

Python code has a simple and clean structure that is easy to learn and easy to read. In fact, as you will see, the language definition enforces code structure that is easy to read.

Python代码具有简单干净的结构,易于学习和阅读。 实际上,正如您将看到的,语言定义强制执行了易于阅读的代码结构。

但这不是那么简单 (But It’s Not That Simple)

For all its syntactical simplicity, Python supports most constructs that would be expected in a very high-level language, including complex dynamic data types, structured and functional programming, and object-oriented programming.

尽管语法简单,但Python支持大多数用高级语言编写的构造,包括复杂的动态数据类型,结构化和函数式编程以及面向对象的编程。

Additionally, a very extensive library of classes and functions is available that provides capability well beyond what is built into the language, such as database manipulation or GUI programming.

此外,还提供了非常丰富的类和函数库,它提供的功能远远超出了语言内置的功能,例如数据库操作或GUI编程。

Python accomplishes what many programming languages don’t: the language itself is simply designed, but it is very versatile in terms of what you can accomplish with it.

Python可以完成许多编程语言所不能完成的工作:语言本身是经过简单设计的,但是就可以完成的工作而言,它具有多种用途。

结论 (Conclusion)

This section gave an overview of the Python programming language, including:

本节概述了Python编程语言,包括:

  • A brief history of the development of Python
  • Some reasons why you might select Python as your language of choice
  • Python开发简史
  • 选择Python作为您选择的语言的一些原因

Python is a great option, whether you are a beginning programmer looking to learn the basics, an experienced programmer designing a large application, or anywhere in between. The basics of Python are easily grasped, and yet its capabilities are vast.

无论您是希望学习基础知识的入门程序员,还是经验丰富的设计大型应用程序的程序员,或者介于两者之间,Python都是不错的选择。 Python的基本知识很容易掌握,但是其功能却很丰富。

Proceed to the next section to learn how to acquire and install Python on your computer.

继续下一节,学习如何在计算机上获取和安装Python。

Get Notified: Don’t miss the follow up to this tutorial—Click here to join the Real Python Newsletter and you’ll know when the next instalment comes out.

通知您:不要错过本教程的后续内容- 单击此处加入Real Python Newslet ,您将知道下一期的发行时间。

翻译自: https://www.pybloggers.com/2018/05/introduction-to-python-3/

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 扫一扫,分享海报

参与评论 您还未登录,请先 登录 后发表或查看评论
©️2022 CSDN 皮肤主题:编程工作室 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值