Beginning Python Chapter 1 Notes】的更多相关文章

James Payne(American)编写的<Beginning Python>中文译作<Python入门经典>,堪称是Python的经典著作. 当然安装Python是很简单的,下载地址为:http://www.python.org/download/ .由于Python需要在注册表中进行注册,因此需要配置相应的环境变量(略). 1.Python Shell 简介 Python初学者最实用的工具就是Python IDLE(Python GUI)---Python Shell,如…
变量(variable)是储存数据的实体,在Python中也被称为"名称"(name). 1.Python"名称"基本命名法则 1.1) "名称"不能是Python的内置词(保留字.关键字). 1.2) "名称"由数字.下划线.字母组成. Python关键字表以及其余约定俗称的规则将在另一篇文章中详细阐述. 原文的排版也是醉了,讲名称时又讲起了内置数据类型.为了尊重原文,所以下面还是谈谈Python的另外几种基本数据类型:元组…
Python基本数据类型用Python官方说法应该叫Python内建数据类型,英文叫built-in type.下面稍微总结了一下我看到过的Python内建数据类型. Python基本数据类型 数据类型 具体的数据类型 说明 Numbers Integer => int Python2.3开始数据超出int范围可以自动转到long,而之前版本Python解释器会报错 Long Integer => long Python3.x版本均将long型归入int型,即type(10**20)结果为&l…
<Web Scraping with Python> Chapter 1 & 2: Your First Web Scraper & Advanced HTML Parsing BeautifulSoup Key:     P5: urlib or urlib2?  If you’ve used the urllib2 library in Python 2.x, you might have noticed that things have changed somewhat…
In this chapter I present classes to represent playing cards, decks of cards, and poker hands.If you don't play poker, you can read about it at http://en.wikipedia.org/wiki/Poker, but you don’t have to; I’ll tell you what you need to know for the exe…
17.1 Object-oriented featuresPython is an object-oriented programming language, which means that it provides features that support object-oriented programming.It is not easy to define object-oriented programming, but we have already seen some of its…
16.1 TimeAs another example of a user-defined type, we’ll define a class called Time that records the time of day. The class definition looks like this: class Time(object): """Represents the time of day. attributes: hour, minute, second &qu…
12.1 Tuples are immutable(元组是不可变的)A tuple is a sequence of values. The values can be any type, and they are indexed by integers, so in that respect tuples are a lot like lists. The important difference is that tuples are immutable.Syntactically, a tu…
Dictionaries A dictionary is like a list, but more general. In a list, the indices have to be integers; in a dictionary they can be (almost) any type.You can think of a dictionary as a mapping between a set of indices (which are called keys) and a se…
10.1 A list is a sequenceLike a string, a list is a sequence of values. In a string, the values are characters; in a list, they can be any type. The values in a list are called elements or sometimes items.There are several ways to create a new list;…