Skip to Content
Python 技術手冊 第三版
book

Python 技術手冊 第三版

by lex Martelli, Anna Martelli Ravenscroft, Steve Holden
January 2018
Intermediate to advanced
856 pages
17h 17m
Chinese
GoTop Information, Inc.
Content preview from Python 技術手冊 第三版
690
|
22 章 結構化文字:HTML
搜尋方法的引數
每個搜尋方法都有三個選擇性引數:
name
attrs
string
name
string
過濾器
filters
,如本節後面中所描述的;
attrs
是一個
dict
,也會
在本節後面描述。此外,僅限於
find
find_all
(而不適用其他搜尋方
法),可選擇性地以引數
recursive=False
被呼叫,以限制在子節點中搜
尋,而非所有的子裔。
任何會回傳一個串列的搜尋方法(即名稱為複數的,或以
find_all
開頭
的)都可以有選擇性的具名引數
limit
,若有傳入,其值就會是一個整數,
對所回傳的串列設下長度的一個上界。
在這些選擇性引數之後,每個搜尋方法都可以選擇性地有任何數目的任意
具名引數,其名稱可以是任何的識別字(除了搜尋方法的特定引數之名
稱),而其值為一個過濾器。
搜尋方法引數:過濾器
一個
過濾器
filter
會被套用到一個
目標
target
,這個目標可以是
一個標記的名稱(傳入作為
name
引數時)、一個
Tag
string
或一個
NavigableString
的文字內容(傳入作為
string
時),或一個
Tag
的屬性
(傳入作為具名引數的值,或在
attrs
中傳入時)。每個過濾器可以是:
一個
Unicode
字串
過濾器會在此字串完全等於目標時匹配成功
一個位元組字串
bytestring
它會以
utf8
被解碼為 Unicode,然後過濾器會在所產生的 Unicode
串完全等於目標時,匹配成功
一個正規表達式物件
RE
re.compile ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

利用 Python 进行数据分析(原书第2版)

利用 Python 进行数据分析(原书第2版)

Wes McKinney

Publisher Resources

ISBN: 9789864766819