Think Python - Chapter 8 - Strings】的更多相关文章

8.1 A string is a sequenceA string is a sequence of characters. You can access the characters one at a time with the bracket operator: >>> fruit = 'banana' >>> letter = fruit[1] The second statement selects character number 1 from fruit…
<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…
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;…
3.1 Function callsIn the context of programming, a function is a named sequence of statements that performs a computation. When you define a function, you specify the name and the sequence of statements. Later, you can “call” the function by name. We…
一年之前,我做梦也想不到会来这里写技术总结.误打误撞来到了上海西南某高校,成为了文科专业的工科男,现在每天除了膜ha,就是恶补CS.导师是做计算语言学的,所以当务之急就是先自学计算机自然语言处理,打好底子准备做科研(认真脸). 进入正题,从图书馆找了本“Natural Language Processing with Python” (影印版),书长这个样子,作者是Steven Bird, Ewan Klein和Edward Loper.粘贴个豆瓣链接供参考:https://book.douba…
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…