官术网_书友最值得收藏!

  • Python Essentials
  • Steven F. Lott
  • 265字
  • 2021-07-16 13:53:10

Summary

We've looked at some core data types available in Python. We've looked at five different kinds of numbers, including integers, floating-point, complex, Fraction and Decimal. Each fills a different niche. Three of these are built-in, the other two must be imported from the standard library.

We've also looked at three different kinds of collections. The tuple is a simple sequence of items with relatively few methods. str is a Unicode string, which has several methods for creating new strings as transformations of existing strings. bytes is a byte string, which also has a variety of methods. We can decode bytes to create Unicode strings. We can encode Unicode strings into bytes.

We've touched on how the import statement is used to introduce new types and new modules. This will add features from the standard library.

We've also looked at a number of functions to convert various numeric types. Many of these functions also convert strings to numbers. We'll make heavy use of int() and float() to convert strings to numbers. The reverse—converting numbers to strings—can be done with the str() function. It can be done better, however, with the formatting tools we'll look at in the next chapter.

In Chapter 3, Expressions and Output, we'll build on these basic concepts. We'll look in more depth at Python language syntax. We'll also look at functions for creating nicely formatted output. This will allow us to write simple programs. In Chapter 4, Variables, Assignment and Scoping Rules, we'll add even more essential language features so that we can write more sophisticated programs.

主站蜘蛛池模板: 海淀区| 民和| 绍兴市| 屏边| 苏尼特左旗| 济源市| 当阳市| 郑州市| 囊谦县| 双江| 珠海市| 清苑县| 琼结县| 绥棱县| 安平县| 秦皇岛市| 米脂县| 五台县| 土默特右旗| 黄浦区| 阿克苏市| 康乐县| 金溪县| 新平| 兴化市| 綦江县| 教育| 万载县| 洛阳市| 潮州市| 沙田区| 祁门县| 应城市| 徐水县| 乌兰察布市| 汉阴县| 丰县| 永兴县| 湖北省| 微山县| 垫江县|