BeautifulSoup解析 HTML标签Tag及属性attrs的常用方法

# 使用 BeautifulSoup 解析 HTML 内容
# BeautifulSoup 对象表示整个解析树或文档,可以用来遍历、搜索和操作文档。

# 常用方法: 
# find(name, attrs, recursive, text, **kwargs):在文档中查找第一个符合条件的元素,并返回该元素的 Tag 对象。
# find_all(name, attrs, recursive, text, limit, **kwargs):在文档中查找所有符合条件的元素,并返回一个列表。
# find_parent(name, attrs, recursive, text, **kwargs):查找父元素并返回其 Tag 对象。
# find_next_sibling(name, attrs, recursive, text, **kwargs):查找下一个同级元素并返回其 Tag 对象。
# get_text(separator, strip, types):获取文档中的所有文本内容,并返回一个字符串或列表。
# prettify(formatter, encoding, newline, indent_level):将文档格式化后返回一个字符串,通常用于输出美观的HTML代码。
# select(selector):使用 CSS 选择器语法来查找元素,并返回一个列表。
# select_one(selector):使用 CSS 选择器语法来查找第一个符合条件的元素,并返回其 Tag 对象。
# 当使用 BeautifulSoup 的 find 方法查找标签元素时,可以根据不同的需求使用不同的方式来定位目标标签。下面是一些常用的方式和示例:
# 通过标签名称查找:tag = soup.find('a')  # 查找第一个<a>标签
# 通过指定标签属性查找:tag = soup.find('a', {'class': 'example'})  # 查找第一个class为'example'的<a>标签
# 通过 CSS 类名查找:tag = soup.find(class_='example')  # 查找第一个class为'example'的标签
# 通过 ID 查找:tag = soup.find(id='example')  # 查找id为'example'的标签
# 通过正则表达式查找:tag = soup.find(text=re.compile('example'))  # 查找文本内容包含'example'的标签
# 通过自定义函数查找:
# def has_class_but_no_id(tag):
#     return tag.has_attr('class') and not tag.has_attr('id')
# tag = soup.find(has_class_but_no_id)  # 查找具有class属性但没有id属性的任意标签
# 结合多个属性查找:tag = soup.find('a', {'class': 'example', 'id': 'link'})  # 查找第一个同时具有class为'example'和id为'link'的<a>标签
# 多个条件逻辑组合查找:tag = soup.find('a', class_='example', id='link')  # 查找第一个同时具有class为'example'和id为'link'的<a>标签
# 使用 CSS 选择器语法查找:tag = soup.select_one('a.example#link')  # 使用CSS选择器语法查找class为'example'且id为'link'的<a>标签
# 查找特定位置的标签:tag = soup.find_all('a')[2]  # 获取第三个<a>标签(索引从0开始)
# 查找父节点中的特定子节点:
# parent_tag = soup.find('div', id='parent')
# child_tag = parent_tag.find('a')  # 在id为'parent'的<div>标签中查找第一个<a>标签
# 查找包含特定文本的标签:
# tag = soup.find(text='Example text')  # 查找第一个包含文本 'Example text' 的标签


# 示例 HTML 内容
# html_content = '''
# <div class="container">
#     <p class="paragraph">Paragraph 1</p>
#     <p class="paragraph">Paragraph 2</p>
#     <div id="footer">Footer</div>
# </div>
# '''
# ****通过标签名称查找:paragraphs = soup.find_all('p')
# ****查通过指定标签属性查找:soup.find_all('p', class_='paragraph')
# ****使用正则表达式查找所有以 "Para" 开头的文本:regex_paragraphs = soup.find_all(text=re.compile(r'^Para'))
# ****限制返回结果数量为 1:limited_results = soup.find_all('p', limit=1)
# ****使用 attrs 参数查找具有特定属性的标签:soup.find_all(attrs={'class': 'paragraph'})
# ****通过 CSS 类名查找:soup.find(class_='example')  # 查找第一个class为'example'的标签
# ****通过 ID 查找:soup.find(id='example')  # 查找id为'example'的标签
 

# select() 方法时,通过 CSS 选择器来查找特定的元素
# 通过类名查找元素: elements = soup.select('div.content')
# 通过 ID 查找元素: element = soup.select('div#header')
# 通过标签名查找元素: elements = soup.select('a')
# 通过组合选择器查找元素: listitems = soup.select('ul.menu li')查找class为menu的ul元素下的所有li子元素 

# 字典推导式{key_expression: value_expression for item in iterable}
# numbers = [1, 2, 3, 4, 5]
# squared_dict = {x: x ** 2 for x in numbers}
# print(squared_dict)
# 获取 <a> 标签中的 href 和 title 属性的取值,存储在字典 attrs 中
# 在示例代码中,['href', 'title'] 是一个硬编码的固定列表,用于指定要提取的属性名。
# 最终生成一个包含 {'href': link.get('href'), 'title': link.get('title')} 的字典

from bs4 import BeautifulSoup# 假设这是您要解析的 HTML 内容
html_content = """
<html>
<body>
<div class='httpweb' id='daohangweb'>
<a href="https://www.example.com" title="example">example.com Link sample</a>
<a href="https://www.guancha.cn/" title="guancha">guancha Link sample</a><div class="child"><p>Paragraph 1</p><p>Paragraph 2</p></div>
</div>
</body>
</html>
"""# 使用 BeautifulSoup 解析 HTML 内容
# BeautifulSoup 对象表示整个解析树或文档,可以用来遍历、搜索和操作文档。
# 常用方法: 
# find(name, attrs, recursive, text, **kwargs):在文档中查找第一个符合条件的元素,并返回该元素的 Tag 对象。
# find_all(name, attrs, recursive, text, limit, **kwargs):在文档中查找所有符合条件的元素,并返回一个列表。
# find_parent(name, attrs, recursive, text, **kwargs):查找父元素并返回其 Tag 对象。
# find_next_sibling(name, attrs, recursive, text, **kwargs):查找下一个同级元素并返回其 Tag 对象。
# get_text(separator, strip, types):获取文档中的所有文本内容,并返回一个字符串或列表。
# prettify(formatter, encoding, newline, indent_level):将文档格式化后返回一个字符串,通常用于输出美观的HTML代码。
# select(selector):使用 CSS 选择器语法来查找元素,并返回一个列表。
# select_one(selector):使用 CSS 选择器语法来查找第一个符合条件的元素,并返回其 Tag 对象。
# 示例 HTML 内容
# html_content = '''
# <div class="container">
#     <p class="paragraph">Paragraph 1</p>
#     <p class="paragraph">Paragraph 2</p>
#     <div id="footer">Footer</div>
# </div>
# '''
# ****通过标签名称查找:paragraphs = soup.find_all('p')
# ****查通过指定标签属性查找:soup.find_all('p', class_='paragraph')
# ****使用正则表达式查找所有以 "Para" 开头的文本:regex_paragraphs = soup.find_all(text=re.compile(r'^Para'))
# ****限制返回结果数量为 1:limited_results = soup.find_all('p', limit=1)
# ****使用 attrs 参数查找具有特定属性的标签:soup.find_all(attrs={'class': 'paragraph'})
# ****通过 CSS 类名查找:soup.find(class_='example')  # 查找第一个class为'example'的标签
# ****通过 ID 查找:soup.find(id='example')  # 查找id为'example'的标签
# ****通过自定义函数查找:
# def has_class_but_no_id(tag):
#     return tag.has_attr('class') and not tag.has_attr('id')
# tag = soup.find(has_class_but_no_id)  # 查找具有class属性但没有id属性的任意标签# 当使用 BeautifulSoup 的 find 方法查找标签元素时,可以根据不同的需求使用不同的方式来定位目标标签。下面是一些常用的方式和示例:
# 通过标签名称查找:tag = soup.find('a')  # 查找第一个<a>标签
# 通过指定标签属性查找:tag = soup.find('a', {'class': 'example'})  # 查找第一个class为'example'的<a>标签
# 通过 CSS 类名查找:tag = soup.find(class_='example')  # 查找第一个class为'example'的标签
# 通过 ID 查找:tag = soup.find(id='example')  # 查找id为'example'的标签
# 通过正则表达式查找:tag = soup.find(text=re.compile('example'))  # 查找文本内容包含'example'的标签
# 通过自定义函数查找:
# def has_class_but_no_id(tag):
#     return tag.has_attr('class') and not tag.has_attr('id')
# tag = soup.find(has_class_but_no_id)  # 查找具有class属性但没有id属性的任意标签
# 结合多个属性查找:tag = soup.find('a', {'class': 'example', 'id': 'link'})  # 查找第一个同时具有class为'example'和id为'link'的<a>标签
# 多个条件逻辑组合查找:tag = soup.find('a', class_='example', id='link')  # 查找第一个同时具有class为'example'和id为'link'的<a>标签
# 使用 CSS 选择器语法查找:tag = soup.select_one('a.example#link')  # 使用CSS选择器语法查找class为'example'且id为'link'的<a>标签
# 查找特定位置的标签:tag = soup.find_all('a')[2]  # 获取第三个<a>标签(索引从0开始)
# 查找父节点中的特定子节点:
# parent_tag = soup.find('div', id='parent')
# child_tag = parent_tag.find('a')  # 在id为'parent'的<div>标签中查找第一个<a>标签
# 查找包含特定文本的标签:
# tag = soup.find(text='Example text')  # 查找第一个包含文本 'Example text' 的标签soup = BeautifulSoup(html_content, 'html.parser')# 获取 class 为 "child" 的 div 标签
child_div = soup.find('div', class_='child')# 使用 contents 获取直接子节点  #使用 parent 获取父节点# 
print("div 标签class_='child' child Contents:", child_div.contents)# 使用 children 获取直接子节点迭代器
print("div 标签class_='child' Children:")
for child in child_div.children:if child == '\n':passelse:print(child)# 获取标签的所有子孙节点
tagall=[]
for tag in soup.descendants:if tag.name:tagall.append(tag.name)
print('获取标签的所有子孙节点:',tagall)# 获取经过 .strip() 后不为空的文本内容并连接成一个字符串
text_content = '; '.join(s.strip() for s in soup.strings if s.strip())
print(type(text_content))
print("提取标签内的所有文本内容:",text_content)# select() 方法时,通过 CSS 选择器来查找特定的元素
# 通过类名查找元素: elements = soup.select('div.content')
# 通过 ID 查找元素: element = soup.select('div#header')
# 通过标签名查找元素: elements = soup.select('a')
# 通过组合选择器查找元素: listitems = soup.select('ul.menu li')查找class为menu的ul元素下的所有li子元素# CSS选择器通过组合选择器查找元素
divs = soup.select('div.httpweb a')
print("查找div.httpweb下的a签名")
for div in divs:if div == '\n':passelse:print(div)# Tag对象表示 HTML/XML 文档中的一个标签元素,可以访问标签的属性、内容等信息。
# 常用方法:
# get(): 获取指定属性的值。p_tag.get('class')
# text: 获取标签内的文本内容。
# find(), find_all(): 在当前标签下查找子元素。
# 找到<a> 标签内的text
link = soup.find('a')
text_string = link.text
print(f'\n第一个a标签内的字符串:{text_string}\n')# 找到所有 <a> 标签
links = soup.find_all('a')# 字典推导式{key_expression: value_expression for item in iterable}
# numbers = [1, 2, 3, 4, 5]
# squared_dict = {x: x ** 2 for x in numbers}
# print(squared_dict)
# 获取 <a> 标签中的 href 和 title 属性的取值,存储在字典 attrs 中
# 在示例代码中,['href', 'title'] 是一个硬编码的固定列表,用于指定要提取的属性名。
# 最终生成一个包含 {'href': link.get('href'), 'title': link.get('title')} 的字典
# 找到所有 <a> 标签# 初始化一个空列表,用于存储每个 <a> 标签的属性字典
# 提取多个属性值:可以同时提取多个属性的值,并存储在字典中
attrs_list = []# 遍历每个 <a> 标签
for link in links:print(f'打印标签的文本:{link.text}')# 获取当前 <a> 标签的 href 和 title 属性的取值attrs = {attr: link.get(attr) for attr in ['href', 'title']}# 将属性字典添加到列表中attrs_list.append(attrs)# 打印获取到的属性值列表
print(attrs_list)

# Tag类是 BeautifulSoup 库中非常重要的类之一,用于表示 HTML 或 XML 文档中的一个标签元素。
# 通过 Tag对象,我们可以访问标签的属性、内容等信息。
# 以下是 Tag 类常用的一些方法和属性:
# name:获取标签的名称。
# attrs:获取标签的属性字典。
# string:获取标签内的文本内容,如果标签内只有一个 NavigableString 对象,则返回该字符串;如果有多个子节点,则返回 None。
# get(key, default):获取指定属性的值,如果属性不存在则返回默认值。
# find(name, attrs, recursive, text, **kwargs):在当前标签内查找第一个符合条件的元素,并返回其 Tag 对象。
# find_all(name, attrs, recursive, text, limit, **kwargs):在当前标签内查找所有符合条件的元素,并返回一个列表。
# find_parent(name, attrs, recursive, text, **kwargs):查找当前标签的父元素并返回其 Tag 对象。
# find_next_sibling(name, attrs, recursive, text, **kwargs):查找当前标签的下一个同级元素并返回其 Tag 对象。
# get_text(separator, strip, types):获取当前标签内的所有文本内容,并返回一个字符串或列表。
# prettify(formatter, encoding, newline, indent_level):将当前标签及其子孙元素格式化后返回一个字符串。

from bs4 import BeautifulSoup# 示例 HTML 内容
html_content = '''
<html>
<head><title>示例页面</title>
</head>
<body><div id="main-content" class="container"><h1>Welcome to BeautifulSoup</h1><p class="description">BeautifulSoup is a Python library for parsing HTML and XML documents.</p><p class="description">BeautifulSoup is good.</p><a href="https://www.example.com">Visit our website</a></div>
</body>
</html>
'''# 创建 BeautifulSoup 对象
soup = BeautifulSoup(html_content, 'html.parser')# 获取<div>标签的属性字典
div_tag = soup.find('div')
div_attrs = div_tag.attrs
print("div标签的属性字典:", div_attrs)# 找到<h1>标签并获取文本内容
h1_tag = soup.find('h1')
h1_text = h1_tag.get_text()
print("h1标题文本内容:", h1_text)# 获取<p>标签的文本内容
p_tag = soup.find('p')
p_text = p_tag.string 
# string:获取标签内的文本内容,如果标签内只有一个 NavigableString 对象,则返回该字符串;如果有多个子节点,则返回 None。
print("p标签的文本内容:", p_text)# 获取<div>标签的class属性值
div_tag = soup.find('div')
div_class = div_tag.get('class')
print("div标签的class属性值:", div_class)# 获取<p>标签的class属性值
p_tag = soup.find('p')
p_class = p_tag.get('class')
print("p标签的class属性值:", p_class)# 获取<a>标签的href属性值
a_tag = soup.find('a')
a_href = a_tag.get('href')
print("a标签的href属性值:", a_href)# Tag类是 BeautifulSoup 库中非常重要的类之一,用于表示 HTML 或 XML 文档中的一个标签元素。
# 通过 Tag对象,我们可以访问标签的属性、内容等信息。
# 以下是 Tag 类常用的一些方法和属性:
# name:获取标签的名称。
# attrs:获取标签的属性字典。
# string:获取标签内的文本内容,如果标签内只有一个 NavigableString 对象,则返回该字符串;如果有多个子节点,则返回 None。
# get(key, default):获取指定属性的值,如果属性不存在则返回默认值。
# find(name, attrs, recursive, text, **kwargs):在当前标签内查找第一个符合条件的元素,并返回其 Tag 对象。
# find_all(name, attrs, recursive, text, limit, **kwargs):在当前标签内查找所有符合条件的元素,并返回一个列表。
# find_parent(name, attrs, recursive, text, **kwargs):查找当前标签的父元素并返回其 Tag 对象。
# find_next_sibling(name, attrs, recursive, text, **kwargs):查找当前标签的下一个同级元素并返回其 Tag 对象。
# get_text(separator, strip, types):获取当前标签内的所有文本内容,并返回一个字符串或列表。
# prettify(formatter, encoding, newline, indent_level):将当前标签及其子孙元素格式化后返回一个字符串。# 当使用 BeautifulSoup 的 find 方法查找标签元素时,可以根据不同的需求使用不同的方式来定位目标标签。下面是一些常用的方式和示例:
# 通过标签名称查找:tag = soup.find('a')  # 查找第一个<a>标签
# 通过指定标签属性查找:tag = soup.find('a', {'class': 'example'})  # 查找第一个class为'example'的<a>标签
# 通过 CSS 类名查找:tag = soup.find(class_='example')  # 查找第一个class为'example'的标签
# 通过 ID 查找:tag = soup.find(id='example')  # 查找id为'example'的标签
# 通过正则表达式查找:tag = soup.find(text=re.compile('example'))  # 查找文本内容包含'example'的标签
# 通过自定义函数查找:
# def has_class_but_no_id(tag):
#     return tag.has_attr('class') and not tag.has_attr('id')
# tag = soup.find(has_class_but_no_id)  # 查找具有class属性但没有id属性的任意标签
# 结合多个属性查找:tag = soup.find('a', {'class': 'example', 'id': 'link'})  # 查找第一个同时具有class为'example'和id为'link'的<a>标签
# 多个条件逻辑组合查找:tag = soup.find('a', class_='example', id='link')  # 查找第一个同时具有class为'example'和id为'link'的<a>标签
# 使用 CSS 选择器语法查找:tag = soup.select_one('a.example#link')  # 使用CSS选择器语法查找class为'example'且id为'link'的<a>标签
# 查找特定位置的标签:tag = soup.find_all('a')[2]  # 获取第三个<a>标签(索引从0开始)
# 查找父节点中的特定子节点:
# parent_tag = soup.find('div', id='parent')
# child_tag = parent_tag.find('a')  # 在id为'parent'的<div>标签中查找第一个<a>标签
# 查找包含特定文本的标签:
# tag = soup.find(text='Example text')  # 查找第一个包含文本 'Example text' 的标签

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/710492.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Java面试值之集合

集合 1.HashMap底层&#xff1f;扩容机制&#xff1f;1.7-1.8的升级&#xff1f;2.HashMap的长度为什么是2的幂次方&#xff1f;3.HashMap 插入1.7和1.8的区别&#xff1f;4.什么是红黑树&#xff1f;O(logn)5.HashMap为什么会使用红黑树&#xff1f;6.ArrayList底层&#xff1…

鸿蒙(HarmonyOS)项目方舟框架(ArkUI)之FlowItem容器组件

鸿蒙&#xff08;HarmonyOS&#xff09;项目方舟框架&#xff08;ArkUI&#xff09;之FlowItem容器组件 一、操作环境 操作系统: Windows 10 专业版、IDE:DevEco Studio 3.1、SDK:HarmonyOS 3.1 二、FlowItem组件 子组件 可以包含子组件。 接口 FlowItem() 使用该接口来…

免费音频剪辑

在数字时代&#xff0c;音频剪辑已成为许多职业和爱好者不可或缺的技能。无论是制作播客、教育视频、还是进行广告宣传&#xff0c;高质量的音频剪辑都能为作品增色不少。今天&#xff0c;我要为大家强烈安利一款免费且功能强大的音频剪辑工具&#xff0c;它绝对是你办公桌上不…

Kotti-基于Python的开源内容管理系统介绍与使用

前言 Kotti是一个基于Python的开源内容管理系统&#xff08;CMS&#xff09;&#xff0c;旨在为开发人员提供快速、简单和灵活的方式来构建Web应用。它基于Pyramid框架&#xff0c;使用SQLAlchemy进行数据库管理&#xff0c;支持自定义内容类型和可扩展的插件系统。本文将深入…

命令行启动mongodb服务器的问题及解决方案 -- Unrecognized option: storage.journal

目录 mongodb命令行启动问题 -- Unrecognized option: storage.journal问题日志&#xff1a;问题截图&#xff1a;问题来源&#xff1a;错误原因&#xff1a;解决方式&#xff1a; mongodb命令行启动问题 – Unrecognized option: storage.journal 同样是格式出问题的问题分析和…

《Spring Security 简易速速上手小册》第5章 高级认证技术(2024 最新版)

文章目录 5.1 OAuth2 和 OpenID Connect5.1.1 基础知识详解OAuth2OpenID Connect结合 OAuth2 和 OIDC 5.1.2 重点案例&#xff1a;使用 OAuth2 和 OpenID Connect 实现社交登录案例 Demo 5.1.3 拓展案例 1&#xff1a;访问受保护资源案例 Demo测试访问受保护资源 5.1.4 拓展案例…

MySQL锁机制【重点】

参考链接 【1】https://xiaolincoding.com/mysql/lock/mysql_lock.html 【2】https://learnku.com/articles/39212?order_byvote_count& 重要的锁&#xff1a; 表级锁&#xff08;Table-level locks&#xff09;&#xff1a; 表级锁是对整个表进行加锁&#xff0c;当一个事…

Blazor 向 ECharts 传递 option

目标 将ECharts封装为Blazor组件&#xff0c;然后通过jsRuntime向ECharts传递参数&#xff0c;即设置option。 封装ECharts 步骤&#xff1a; 1. 在index.html中引入echarts.min.js&#xff1b; 2. 创建blazor组件&#xff0c;将ref传递给js用于初始化echarts&#xff1b; …

#stm学习总结 (二十八)硬件随机数实验

28.1 随机数发生器简介 STM32F407 自带了硬件随机数发生器&#xff08;RNG&#xff09;&#xff0c;RNG 处理器是一个以连续模拟噪声为基础的随机数发生器&#xff0c;在主机读数时提供一个 32 位的随机数。 28.1.1 RNG 框图 STM32F407 的随机数发生器&#xff08;RNG&#x…

ffmpeg单张图片生成固定时长的视频

ffmpeg -r 25 -f image2 -loop 1 -i fps_1.jpg -vcodec libx264 -pix_fmt yuv420p -s 1080*1920 -r 25 -t 30 -y fps.mp4这个命令将 fps_1.jpg 图片转换为一个 30 秒长的视频&#xff0c;分辨率为 1920x1080&#xff0c;帧率为 25 帧/秒&#xff0c;并使用 libx264 编码器进行压…

LeetCode -- 79.单词搜索

1. 问题描述 给定一个 m x n 二维字符网格 board 和一个字符串单词 word 。如果 word 存在于网格中&#xff0c;返回 true &#xff1b;否则&#xff0c;返回 false 。 单词必须按照字母顺序&#xff0c;通过相邻的单元格内的字母构成&#xff0c;其中“相邻”单元格是那些水…

【牛客】SQL125 得分不小于平均分的最低分

描述 请从试卷作答记录表中找到SQL试卷得分不小于该类试卷平均得分的用户最低得分。 示例数据 exam_record表&#xff08;uid用户ID, exam_id试卷ID, start_time开始作答时间, submit_time交卷时间, score得分&#xff09;&#xff1a; iduidexam_idstart_timesubmit_timesc…

kali linux常用命令

1. 网络扫描 功能&#xff1a;网络扫描是用来发现网络中的设备、服务和开放端口的过程。 命令&#xff1a;nmap 例子&#xff1a;nmap -sP 192.168.1.0/24 这个命令使用 Nmap 进行网络扫描&#xff0c;列出 192.168.1.0/24 网段中的所有活跃主机。 2. 密码破解 功能&#xf…

Linux系统——Nginx负载均衡模式

目录 一、Nginx优点 二、Nginx配置项——Conf Upstream 模块 三、Nginx负载均衡 1.负载均衡策略 1.1轮询 1.2IP_hash 1.3URL_hash 1.4Least_conn 1.5Weight 1.6Fair 2.Nginx负载均衡配置状态参数 3.什么是会话保持 3.1会话保持有什么作用呢 3.2Nginx会话保持 3…

《开源软件的影响力》

目录 开源软件的影响力 技术影响力&#xff1a; 经济影响力&#xff1a; 社会影响力&#xff1a; 结论&#xff1a; 开源软件的影响力 简介&#xff1a; 在当今快速发展的科技领域&#xff0c;开源软件已经成为了一种重要的开发模式。本文将重点探讨开源软件对技术、经济和…

用JavaScript动态提取视频中的文字

现阶段整个社会短视频&#xff0c;中视频为王&#xff0c;文字传播虽然被弱化&#xff0c;但在业务中还是有一定的传播价值&#xff0c;今天就来讲一讲如何使用js动态提取视频中的字幕。 先来看看效果&#xff1a; 屏幕录制2024-02-29 15.40.18 一&#xff0c;tesseract.js介…

Android Termux安装MySQL并实现公网远程连接本地数据库

文章目录 前言1.安装MariaDB2.安装cpolar内网穿透工具3. 创建安全隧道映射mysql4. 公网远程连接5. 固定远程连接地址 前言 Android作为移动设备&#xff0c;尽管最初并非设计为服务器&#xff0c;但是随着技术的进步我们可以将Android配置为生产力工具&#xff0c;变成一个随身…

如何解决 C/C++ 编译器优化导致的编译BUG(程序崩溃)支援VC++/CLANG/GCC

本文仅适用于&#xff0c;有愿意、爱捣鼓的童靴。 因编译器优化导致编译BUG&#xff0c;即DEBUG下面无故障稳定工作&#xff0c;但RELESE下程序会在特定函数位置上崩溃。 这要求 C/C 开发人员拥有最基本的素质&#xff0c;需要能够承受&#xff0c;逐行审视编译器输出的目标平…

【二叉搜索树】【递归】【迭代】Leetcode 700. 二叉搜索树中的搜索

【二叉搜索树】【递归】【迭代】Leetcode 700. 二叉搜索树中的搜索 二叉搜索树解法1 递归法解法2 迭代法 ---------------&#x1f388;&#x1f388;题目链接&#x1f388;&#x1f388;------------------- 二叉搜索树 二叉搜索树&#xff08;Binary Search Tree&#xff…

使用Python,maplotlib绘制树型有向层级结构图

使用Python&#xff0c;maplotlib绘制树型有向层级结构图 1. 效果图2. 源码2.1 plotTree.py绘制层级结构及不同样式2.2 plotArrow.py 支持的所有箭头样式 参考 前俩篇博客介绍了 1. 使用Python&#xff0c;networkx对卡勒德胡赛尼三部曲之《群山回唱》人物关系图谱绘制 2. 使用…