Page 9 - Python for Everybody
P. 9
CONTENTS ix
10 Tuples 117 10.1 Tuplesareimmutable ......................... 117 10.2 Comparingtuples ........................... 118 10.3 Tupleassignment............................ 120 10.4 Dictionariesandtuples .........................121 10.5 Multipleassignmentwithdictionaries . . . . . . . . . . . . . . . . 122 10.6 Themostcommonwords ....................... 123 10.7 Usingtuplesaskeysindictionaries.................. 124 10.8 Sequences: strings,lists,andtuples-OhMy! . . . . . . . . . . . . 124 10.9 Debugging ............................... 125 10.10 Glossary................................. 125 10.11 Exercises ................................ 126
11 Regular expressions 127 11.1 Charactermatchinginregularexpressions. . . . . . . . . . . . . . 128 11.2 Extractingdatausingregularexpressions . . . . . . . . . . . . . . 129 11.3 Combiningsearchingandextracting ................. 132 11.4 Escapecharacter............................ 136 11.5 Summary................................ 136 11.6 BonussectionforUnix/Linuxusers................. 137 11.7 Debugging ............................... 138 11.8 Glossary................................. 138 11.9 Exercises ................................ 139
12 Networked programs 141 12.1 HyperTextTransferProtocol-HTTP .................141 12.2 Theworld’ssimplestwebbrowser .................. 142 12.3 RetrievinganimageoverHTTP ................... 144 12.4 Retrievingwebpageswithurllib .................. 146 12.5 Readingbinaryfilesusingurllib .................. 147 12.6 ParsingHTMLandscrapingtheweb ................ 148 12.7 ParsingHTMLusingregularexpressions . . . . . . . . . . . . . . 148 12.8 ParsingHTMLusingBeautifulSoup ................. 150 12.9 BonussectionforUnix/Linuxusers................. 153 12.10 Glossary................................. 153 12.11 Exercises ................................ 154