Python是一种简洁但功能强大的面向对象编程语言,它类似Perl,Ruby,Scheme或Java。
Python的特点:
- 优雅的语法,编写和阅读都很简单。 简单好用,轻松写程序。这个特点让Python做以下工作很方便:开发一个原型或其他特定的小任务,而不用太费劲维护。 内置庞大的标准库,包含常见的编程任务,比如连接网页服务器,用正则表达式搜索文本,读写文件。 Python交互模式可以轻松测试代码片段,也可以使用IDLE的集成开发环境。 也可以轻松扩展用C或C++编译出来的新模块。 可以嵌入软件系统来提供编程接口。 Runs anywhere, including Mac OS X, Windows, Linux, and Unix, with unofficial builds also available for Android and iOS. Is free software in two senses. It doesn't cost anything to download or use Python, or to include it in your application. Python can also be freely modified and re-distributed because while the language is copyrighted it's available under an open-source license.
Some programming-language features of Python are:
- A variety of basic data types are available: numbers (floating point, complex, and unlimited-length long integers), strings (both ASCII and Unicode), lists, and dictionaries. Python supports object-oriented programming with classes and multiple inheritances. Code can be grouped into modules and packages. The language supports raising and catching exceptions, resulting in cleaner error handling. Data types are strongly and dynamically typed. Mixing incompatible types (e.g. attempting to add a string and a number) causes an exception to be raised, so errors are caught sooner. Python contains advanced programming features such as generators and list comprehensions. Python's automatic memory management frees you from having to manually allocate and free memory in your code.
See the SimplePrograms collection of short programs, gradually increasing in length, which shows off Python's syntax and readability.
Writing Pythonic code is not hard---but you have to get used to the (PEP) code style rules. You can test, check, and improve your code style at online resources such as Pythonchecker.com.
Translations: