Beautiful Soup 的 wrap(~)
方法使用指定標簽包裝元素並返回新的包裝器。
例子
考慮以下 html:
my_html = """
<p>Hello <b>World</b></p>
"""
soup = BeautifulSoup(my_html)
要用 <div>
標簽包裝 <b>
標簽:
soup.b.wrap(soup.new_tag("div"))
<div><b>World</b></div>
要用 <div>
標簽包裝 <b>
標簽的 string
:
soup.b.string.wrap(soup.new_tag("div"))
<div>World</div>
相關用法
- Python Tableau workbooks.populate_preview_image用法及代碼示例
- Python wsgiref.simple_server.make_server用法及代碼示例
- Python wsgiref.util.FileWrapper用法及代碼示例
- Python Tableau workbooks.get_by_id用法及代碼示例
- Python Tableau workbooks.update用法及代碼示例
- Python Tableau workbooks.update_connection用法及代碼示例
- Python wsgiref.util.setup_testing_defaults用法及代碼示例
- Python Tableau workbooks.download用法及代碼示例
- Python Tableau workbooks.populate_views用法及代碼示例
- Python OpenCV waitKeyEx()用法及代碼示例
- Python winsound.SND_ALIAS用法及代碼示例
- Python Tableau workbooks.get用法及代碼示例
- Python weakref.WeakMethod用法及代碼示例
- Python Tableau workbooks.publish用法及代碼示例
- Python wsgiref.validate.validator用法及代碼示例
- Python OpenCV waitKey()用法及代碼示例
- Python Tableau workbooks.delete用法及代碼示例
- Python Tableau workbooks.refresh用法及代碼示例
- Python Tableau workbooks.populate_connections用法及代碼示例
- Python Tableau workbooks.populate_pdf用法及代碼示例
- Python NumPy where方法用法及代碼示例
- Python cudf.core.column.string.StringMethods.is_vowel用法及代碼示例
- Python NumPy fliplr方法用法及代碼示例
- Python torch.distributed.rpc.rpc_async用法及代碼示例
- Python torch.nn.InstanceNorm3d用法及代碼示例
注:本文由純淨天空篩選整理自Arthur Yanagisawa大神的英文原創作品 BeautifulSoup | wrap method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。