Python常见面试题的详解24

1. 如何对关键词触发模块进行测试

  • 要点

  • 功能测试:验证正常关键词触发、边界情况及大小写敏感性,确保模块按预期响应不同输入。

  • 性能测试:关注响应时间和并发处理能力,保证模块在不同负载下的性能表现。

  • 兼容性测试:测试不同输入方式、操作系统和浏览器下模块的工作情况,提升其通用性。

python

import time
import threading# 关键词触发模块示例
keyword_mapping = {"hello": "Hello! How can I help you?","bye": "Goodbye! Have a nice day."
}def keyword_trigger(keyword):if keyword in keyword_mapping:return keyword_mapping[keyword]return "No relevant response."# 功能测试 - 正常关键词触发
def test_normal_trigger():test_keyword = "hello"result = keyword_trigger(test_keyword)print(f"Testing normal keyword '{test_keyword}': {result}")# 功能测试 - 边界情况测试(假设关键词长度范围 1 - 10)
def test_boundary_trigger():short_keyword = "a"long_keyword = "a" * 10print(f"Testing short keyword '{short_keyword}': {keyword_trigger(short_keyword)}")print(f"Testing long keyword '{long_keyword}': {keyword_trigger(long_keyword)}")# 功能测试 - 大小写敏感性测试
def test_case_sensitivity():test_keyword = "Hello"result = keyword_trigger(test_keyword)print(f"Testing case - sensitive keyword '{test_keyword}': {result}")# 性能测试 - 响应时间测试
def test_response_time():test_keyword = "bye"start_time = time.time()response = keyword_trigger(test_keyword)end_time = time.time()print(f"Response time for keyword '{test_keyword}': {end_time - start_time} seconds")# 性能测试 - 并发测试
def concurrent_trigger(keyword):result = keyword_trigger(keyword)print(f"Concurrent test result for '{keyword}': {result}")def test_concurrency():threads = []keyword = "hello"for _ in range(10):  # 模拟 10 个并发请求thread = threading.Thread(target=concurrent_trigger, args=(keyword,))threads.append(thread)thread.start()for thread in threads:thread.join()# 兼容性测试 - 模拟不同输入方式(文件输入)
def test_compatibility_file_input():with open('test_keywords.txt', 'w') as f:f.write("hello\nbye")with open('test_keywords.txt', 'r') as f:for line in f:keyword = line.strip()result = keyword_trigger(keyword)print(f"Testing keyword from file '{keyword}': {result}")if __name__ == "__main__":test_normal_trigger()test_boundary_trigger()test_case_sensitivity()test_response_time()test_concurrency()test_compatibility_file_input()

  • 补充知识点

  • 可以引入更多的关键词规则,如支持关键词的模糊匹配,使用正则表达式来处理更复杂的关键词匹配逻辑。

  • 对于并发测试,可以使用专业的性能测试工具如 locust 进行更全面的性能分析,模拟大量用户的并发请求。

  • 在兼容性测试方面,可以进一步测试不同编码格式的文件输入,以及在不同 Python 版本下的兼容性。

2. 说明测试人员在软件开发过程中的任务

  • 要点

  • 需求分析阶段:参与评审,从测试角度确保需求完整、准确、可测试,并理解软件功能与非功能需求。

  • 测试计划阶段:制定测试计划,明确范围、方法、进度,确定所需资源。

  • 测试设计阶段:依据需求和设计文档设计全面的测试用例,准备各类测试数据。

  • 测试执行阶段:执行用例,记录结果,发现并跟踪缺陷,推动问题解决。

  • 测试总结阶段:分析结果,评估软件质量,编写详细测试报告。

python

import datetime# 模拟测试计划制定
class TestPlan:def __init__(self, scope, method, schedule, resources):self.scope = scopeself.method = methodself.schedule = scheduleself.resources = resourcesdef print_plan(self):print(f"Test Scope: {self.scope}")print(f"Test Method: {self.method}")print(f"Test Schedule: {self.schedule}")print(f"Test Resources: {self.resources}")# 模拟测试用例设计
class TestCase:def __init__(self, case_id, description, input_data, expected_output):self.case_id = case_idself.description = descriptionself.input_data = input_dataself.expected_output = expected_outputdef print_case(self):print(f"Test Case ID: {self.case_id}")print(f"Description: {self.description}")print(f"Input Data: {self.input_data}")print(f"Expected Output: {self.expected_output}")# 模拟测试执行和结果记录
class TestExecution:def __init__(self, test_case):self.test_case = test_caseself.actual_output = Noneself.result = Noneself.execution_time = Nonedef execute(self):# 这里简单模拟执行,实际中应调用被测试的功能self.actual_output = f"Simulated output for {self.test_case.input_data}"self.result = self.actual_output == self.test_case.expected_outputself.execution_time = datetime.datetime.now()print(f"Test Case ID: {self.test_case.case_id}, Result: {'Pass' if self.result else 'Fail'}")# 模拟测试总结
class TestSummary:def __init__(self, test_executions):self.test_executions = test_executionsself.passed_count = sum([1 for exec in test_executions if exec.result])self.failed_count = len(test_executions) - self.passed_countdef print_summary(self):print(f"Total Test Cases: {len(self.test_executions)}")print(f"Passed: {self.passed_count}")print(f"Failed: {self.failed_count}")print("Overall Software Quality: Good" if self.failed_count == 0 else "Needs Improvement")# 制定测试计划
scope = "User registration and login functions"
method = "Functional testing"
schedule = "Week 1 - Design test cases, Week 2 - Execute tests"
resources = "Test environment: Local server, Test tools: Selenium"
test_plan = TestPlan(scope, method, schedule, resources)
test_plan.print_plan()# 设计测试用例
test_case_1 = TestCase(1, "Register a new user", {"username": "testuser", "password": "testpass"}, "Registration successful")
test_case_2 = TestCase(2, "Login with valid credentials", {"username": "testuser", "password": "testpass"}, "Login successful")
test_case_1.print_case()
test_case_2.print_case()# 执行测试用例
executions = []
for test_case in [test_case_1, test_case_2]:execution = TestExecution(test_case)execution.execute()executions.append(execution)# 测试总结
summary = TestSummary(executions)
summary.print_summary()

  • 补充知识点

  • 可以将测试计划、用例、执行结果等信息存储到数据库中,方便进行更复杂的管理和查询。

  • 引入测试框架如 unittestpytest 来更规范地组织和执行测试用例。

  • 在测试总结阶段,可以生成更详细的报告,如 HTML 格式的报告,包含每个测试用例的详细信息和统计图表。

3. 一条软件 Bug 记录都包含了哪些内容?

  • 要点

软件 Bug 记录涵盖基本信息(编号、标题、发现时间、发现人)、问题描述(重现步骤、实际结果、预期结果)、环境信息(操作系统、浏览器等)、严重程度和优先级,还可附带相关附件。

python

import datetimeclass BugRecord:def __init__(self, bug_id, title, found_time, finder, steps, actual_result, expected_result, os, browser, severity, priority, attachments=None):self.bug_id = bug_idself.title = titleself.found_time = found_timeself.finder = finderself.steps = stepsself.actual_result = actual_resultself.expected_result = expected_resultself.os = osself.browser = browserself.severity = severityself.priority = priorityself.attachments = attachments if attachments else []def print_bug_record(self):print(f"Bug ID: {self.bug_id}")print(f"Title: {self.title}")print(f"Found Time: {self.found_time}")print(f"Finder: {self.finder}")print(f"Steps to Reproduce: {self.steps}")print(f"Actual Result: {self.actual_result}")print(f"Expected Result: {self.expected_result}")print(f"Operating System: {self.os}")print(f"Browser: {self.browser}")print(f"Severity: {self.severity}")print(f"Priority: {self.priority}")if self.attachments:print(f"Attachments: {', '.join(self.attachments)}")# 创建一个 Bug 记录
bug = BugRecord(bug_id=1,title="Login button not working",found_time=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),finder="John",steps="Open the website -> Click on the login button",actual_result="Nothing happens when clicking the login button",expected_result="The login form should pop - up",os="Windows 10",browser="Chrome",severity="High",priority="High",attachments=["screenshot.png"]
)
bug.print_bug_record()

  • 补充知识点

  • 可以实现一个 Bug 管理系统,将 Bug 记录存储到数据库中,支持 Bug 的添加、修改、删除、查询等操作。

  • 为 Bug 记录添加更多的状态信息,如已分配、已修复、已验证等,方便跟踪 Bug 的处理流程。

  • 可以通过邮件或消息通知机制,及时将 Bug 的状态变化通知相关人员。

4. 说明黑盒测试和白盒测试的优缺点

  • 要点

  • 黑盒测试:优点是不依赖代码、从用户角度测试、适用于各种软件;缺点是难以发现内部缺陷、测试用例设计困难、无法进行覆盖测试。

  • 白盒测试:优点是能发现内部缺陷、可进行覆盖测试、有助于代码优化;缺点是依赖代码、测试成本高、不能完全保证功能正确性。

python

import unittest
import coverage# 示例函数
def add_numbers(a, b):return a + b# 黑盒测试示例
class BlackBoxTest(unittest.TestCase):def test_add_numbers(self):test_inputs = [(1, 2), (0, 0), (-1, 1)]for input_pair in test_inputs:result = add_numbers(*input_pair)expected = input_pair[0] + input_pair[1]self.assertEqual(result, expected)# 白盒测试示例
# 这里使用 coverage.py 来统计代码覆盖率
cov = coverage.Coverage()
cov.start()suite = unittest.TestSuite()
suite.addTest(BlackBoxTest("test_add_numbers"))
runner = unittest.TextTestRunner()
runner.run(suite)cov.stop()
cov.report()

  • 补充知识点

  • 对于黑盒测试,可以使用数据驱动测试的方法,通过读取外部数据文件(如 CSV、JSON)来生成更多的测试用例。

  • 白盒测试方面,可以结合静态代码分析工具如 pylintflake8 来发现代码中的潜在问题。

  • 可以使用更复杂的测试框架和工具,如 pytest 来提高测试效率和可维护性。

5. 请列出至少 5 项你所知道的软件测试种类

  • 要点

常见软件测试种类包括功能测试、性能测试、兼容性测试、安全测试、易用性测试、可靠性测试、单元测试、集成测试、系统测试和验收测试。

python

import unittest
import time# 示例函数
def multiply_numbers(a, b):return a * b# 功能测试示例
class FunctionalTest(unittest.TestCase):def test_multiply(self):test_inputs = [(2, 3), (0, 5), (-1, 4)]for input_pair in test_inputs:result = multiply_numbers(*input_pair)expected = input_pair[0] * input_pair[1]self.assertEqual(result, expected)# 性能测试示例
def performance_test():start_time = time.time()for _ in range(1000):multiply_numbers(2, 3)end_time = time.time()print(f"Performance test: {end_time - start_time} seconds for 1000 calls")# 单元测试示例
if __name__ == '__main__':suite = unittest.TestSuite()suite.addTest(FunctionalTest("test_multiply"))runner = unittest.TextTestRunner()runner.run(suite)performance_test()

  • 补充知识点

  • 对于性能测试,可以使用专业的性能测试工具如 locustJMeter 来模拟大量用户的并发请求,进行更全面的性能分析。

  • 兼容性测试可以使用 Selenium 框架来测试不同浏览器和操作系统下的软件表现。

  • 安全测试可以使用 OWASP ZAP 等工具来检测软件的安全漏洞。

6. 说明Alpha 测试与 Beta 测试的区别

  • 要点

  • Alpha 测试:在开发或内部测试环境进行,由开发团队或内部人员执行,目的是全面测试和调试软件。

  • Beta 测试:在实际用户环境进行,由真实用户参与,重点是收集用户反馈和发现实际使用中的问题。

python

# 示例软件功能
def software_function(data):return data.upper()# Alpha 测试
alpha_testers = ["Alice", "Bob"]
alpha_test_data = ["hello", "world"]
alpha_results = []
for tester in alpha_testers:for data in alpha_test_data:result = software_function(data)alpha_results.append((tester, data, result))print(f"Alpha Test by {tester} - Input: {data}, Output: {result}")# Beta 测试
beta_users = ["Eve", "Charlie"]
beta_test_data = ["python", "programming"]
beta_feedbacks = []
for user in beta_users:for data in beta_test_data:result = software_function(data)feedback = input(f"Beta Test by {user} - Input: {data}, Output: {result}. Please provide feedback: ")beta_feedbacks.append((user, data, result, feedback))print(f"Feedback from {user}: {feedback}")# 分析测试结果
print("\nAlpha Test Results:")
for tester, data, result in alpha_results:print(f"{tester} - Input: {data}, Output: {result}")print("\nBeta Test Feedbacks:")
for user, data, result, feedback in beta_feedbacks:print(f"{user} - Input: {data}, Output: {result}, Feedback: {feedback}")

  • 补充知识点

  • 可以使用数据库来存储 Alpha 测试和 Beta 测试的结果和反馈,方便进行数据分析和统计。

  • 开发一个简单的 Web 界面,让用户更方便地参与 Beta 测试和提交反馈。

  • 对反馈进行分类和整理,使用自然语言处理技术来分析用户反馈,提取有价值的信息。

7. 什么是 Bug?一个 bug report 应包含哪些关键字

  • 要点

Bug 是软件不符合预期行为的问题,如电商网站购物车数量更新问题。Bug 报告应包含重现步骤、实际结果、预期结果、严重程度、优先级和环境信息等关键字。

python

# 示例函数,存在 Bug
def divide_numbers(a, b):return a / b# 发现 Bug
try:result = divide_numbers(5, 0)
except ZeroDivisionError:# 模拟 Bug 报告bug_report = {"重现步骤": "调用 divide_numbers 函数,传入参数 (5, 0)","实际结果": "抛出 ZeroDivisionError 异常","预期结果": "应该给出合理的错误提示,而不是抛出异常","严重程度": "高","优先级": "高","环境信息": "Python 3.10"}for

8. 如何找出数组中出现次数超过一半的数字

  • 要点

此问题可以使用摩尔投票法来高效解决。其核心思路是在遍历数组的过程中,维护一个候选元素和一个计数。当计数为 0 时,更换候选元素;若当前元素与候选元素相同则计数加 1,不同则减 1。由于目标数字出现次数超过一半,最后剩下的候选元素即为所求。

python

def majorityElement(nums):# 初始化计数为 0count = 0# 初始化候选元素为 Nonecandidate = None# 遍历数组中的每个数字for num in nums:# 当计数为 0 时,更新候选元素为当前数字if count == 0:candidate = num# 如果当前数字等于候选元素,计数加 1if num == candidate:count += 1# 否则计数减 1else:count -= 1return candidate# 测试示例
nums = [3, 2, 3]
print(majorityElement(nums))  

  • 补充知识点

       1. 输入验证:在函数开始处添加对输入数组的验证,确保数组不为空。

python

def majorityElement(nums):if not nums:return Nonecount = 0candidate = Nonefor num in nums:if count == 0:candidate = numif num == candidate:count += 1else:count -= 1return candidate

       2. 其他方法实现:可以使用哈希表来统计每个数字出现的次数,然后找出出现次数超过一半的数字。

python

def majorityElement(nums):num_count = {}for num in nums:if num in num_count:num_count[num] += 1else:num_count[num] = 1half_length = len(nums) // 2for num, count in num_count.items():if count > half_length:return numreturn None

9. 如何求 100 以内的质数

  • 要点

质数是指大于 1 且只能被 1 和自身整除的正整数。判断一个数是否为质数,可以检查它是否能被 2 到其平方根之间的数整除。通过遍历 2 到 100 的每个数,利用质数判断函数找出所有质数。

python

def is_prime(num):# 小于 2 的数不是质数if num < 2:return False# 检查从 2 到 num 的平方根之间的数是否能整除 numfor i in range(2, int(num**0.5) + 1):if num % i == 0:return Falsereturn True# 使用列表推导式找出 100 以内的质数
primes = [i for i in range(2, 101) if is_prime(i)]
print(primes)

  • 补充知识点

       1. 指定范围的质数查找:将代码封装成函数,接受起始和结束范围作为参数,以查找指定范围内的质数。

python

def find_primes_in_range(start, end):def is_prime(num):if num < 2:return Falsefor i in range(2, int(num**0.5) + 1):if num % i == 0:return Falsereturn Truereturn [i for i in range(start, end + 1) if is_prime(i)]# 测试示例
print(find_primes_in_range(10, 50))

         2. 埃拉托斯特尼筛法:这是一种更高效的质数筛选算法。

python

def sieve_of_eratosthenes(n):primes = [True] * (n + 1)p = 2while p * p <= n:if primes[p]:for i in range(p * p, n + 1, p):primes[i] = Falsep += 1result = []for p in range(2, n + 1):if primes[p]:result.append(p)return resultprint(sieve_of_eratosthenes(100))

10. 如何实现无重复字符的最长子串

  • 要点

使用滑动窗口和哈希表来解决此问题。滑动窗口由左右指针界定,哈希表用于记录每个字符最后出现的位置。遍历字符串时,若遇到重复字符且该字符在当前窗口内,移动左指针到重复字符的下一个位置,同时更新哈希表和最大长度。

python

def lengthOfLongestSubstring(s):# 初始化哈希表,用于记录字符及其最后出现的位置char_index_map = {}# 初始化左指针为 0left = 0# 初始化最大长度为 0max_length = 0# 遍历字符串,右指针从 0 开始for right in range(len(s)):# 如果当前字符在哈希表中,且其最后出现的位置在左指针及之后if s[right] in char_index_map and char_index_map[s[right]] >= left:# 移动左指针到重复字符的下一个位置left = char_index_map[s[right]] + 1# 更新当前字符的最后出现位置char_index_map[s[right]] = right# 计算当前窗口的长度current_length = right - left + 1# 更新最大长度max_length = max(max_length, current_length)return max_length# 测试示例
s = "abcabcbb"
print(lengthOfLongestSubstring(s))  

  • 补充知识点

       1. 优化空间复杂度:可以使用一个固定大小的数组来代替哈希表,以减少空间开销。

python

def lengthOfLongestSubstring(s):char_index = [-1] * 128left = 0max_length = 0for right in range(len(s)):index = ord(s[right])if char_index[index] >= left:left = char_index[index] + 1char_index[index] = rightmax_length = max(max_length, right - left + 1)return max_length

        2. 返回最长子串:对代码进行扩展,不仅返回最长子串的长度,还返回具体的最长子串。

python

def lengthOfLongestSubstring(s):char_index_map = {}left = 0max_length = 0start = 0for right in range(len(s)):if s[right] in char_index_map and char_index_map[s[right]] >= left:left = char_index_map[s[right]] + 1char_index_map[s[right]] = rightcurrent_length = right - left + 1if current_length > max_length:max_length = current_lengthstart = leftreturn s[start:start + max_length]s = "abcabcbb"
print(lengthOfLongestSubstring(s))

11. 如何通过 2 个 5升和6 升的水壶从池塘得到 3 升水

  • 要点

通过一系列倒水操作,利用 5 升和 6 升水壶的容量差,逐步调整两个水壶中的水量,最终在 6 升水壶中得到 3 升水。关键在于合理规划每次倒水的动作。

python

# 初始化 5 升水壶的水量为 0
jug_5 = 0
# 初始化 6 升水壶的水量为 0
jug_6 = 0
# 用于记录操作步骤的列表
steps = []# 开始操作,直到 6 升水壶中有 3 升水
while jug_6 != 3:if jug_6 == 0:# 如果 6 升水壶为空,将其装满jug_6 = 6steps.append("Fill the 6 - liter jug")elif jug_5 == 5:# 如果 5 升水壶已满,将其倒掉jug_5 = 0steps.append("Empty the 5 - liter jug")elif jug_6 > 0 and jug_5 < 5:# 如果 6 升水壶有水且 5 升水壶未满,从 6 升水壶向 5 升水壶倒水pour = min(5 - jug_5, jug_6)jug_5 += pourjug_6 -= poursteps.append(f"Pour water from the 6 - liter jug to the 5 - liter jug: {pour} liters")# 输出操作步骤
for step in steps:print(step)
print(f"Finally, the 6 - liter jug contains {jug_6} liters of water.")

  • 补充知识点

        1. 通用化解决方案:将代码封装成函数,接受两个水壶的容量和目标水量作为参数,以解决更一般的水壶倒水问题。

python

def get_target_water(capacity_1, capacity_2, target):jug_1 = 0jug_2 = 0steps = []while jug_1 != target and jug_2 != target:if jug_2 == 0:jug_2 = capacity_2steps.append(f"Fill the {capacity_2}-liter jug")elif jug_1 == capacity_1:jug_1 = 0steps.append(f"Empty the {capacity_1}-liter jug")elif jug_2 > 0 and jug_1 < capacity_1:pour = min(capacity_1 - jug_1, jug_2)jug_1 += pourjug_2 -= poursteps.append(f"Pour water from the {capacity_2}-liter jug to the {capacity_1}-liter jug: {pour} liters")final_jug = 1 if jug_1 == target else 2for step in steps:print(step)print(f"Finally, the {capacity_1 if final_jug == 1 else capacity_2}-liter jug contains {target} liters of water.")# 测试示例
get_target_water(5, 6, 3)

          2. 使用图论方法:可以将水壶的状态看作图中的节点,倒水操作看作边,使用广度优先搜索(BFS)算法来寻找从初始状态到目标状态的最短路径,以得到最优解。

 友情提示:本文已经整理成文档,可以到如下链接免积分下载阅读

https://download.csdn.net/download/ylfhpy/90435852

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

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

相关文章

前端Javascrip后端Net6前后分离文件上传案例(完整源代码)下载

文件上传功能在项目开发中非常实用&#xff0c;本案例前端用Javascrip实现&#xff0c;后端用Net6实现 前端Javascrip后端Net6前后分离文件上传案例&#xff08;完整源代码&#xff09; 下载链接 https://download.csdn.net/download/luckyext/90437795?spm1001.2014.3001.5…

DeepSeek行业应用实践报告-智灵动力【112页PPT全】

DeepSeek&#xff08;深度搜索&#xff09;近期引发广泛关注并成为众多企业/开发者争相接入的现象&#xff0c;主要源于其在技术突破、市场需求适配性及生态建设等方面的综合优势。以下是关键原因分析&#xff1a; 一、技术核心优势 开源与低成本 DeepSeek基于开源架构&#xf…

C语言综合案例:学生成绩管理系统

C语言综合案例&#xff1a;学生成绩管理系统 需求 1.存储最多50名学生的信息&#xff08;不使用结构体&#xff09; 2.每个学生包含&#xff1a; 学号&#xff08;字符数组&#xff09;姓名&#xff08;字符数组&#xff09;3门课程成绩&#xff08;一维数组&#xff09; …

Day 51 卡玛笔记

这是基于代码随想录的每日打卡 647. 回文子串 给你一个字符串 s &#xff0c;请你统计并返回这个字符串中 回文子串 的数目。 回文字符串 是正着读和倒过来读一样的字符串。 子字符串 是字符串中的由连续字符组成的一个序列。 示例 1&#xff1a; 输入&#xff1a;s &q…

结构型模式---外观模式

概念 外观模式是一种结构型设计模式&#xff0c;它的核心思想是为复杂的子系统提供一个统一的接口&#xff0c;简化客户端与子系统的交互。外观模式通过引入一个高层接口&#xff0c;隐藏子系统的复杂性&#xff0c;使客户端更容易使用。 适用场景 用于客户端无需具体操作子…

DeepSeek开源周第二弹:DeepEP如何用RDMA+FP8让MoE模型飞起来?

一、引言&#xff1a;MoE模型的通信瓶颈与DeepEP的诞生 在混合专家&#xff08;MoE&#xff09;模型训练中&#xff0c;专家间的全对全&#xff08;All-to-All&#xff09;通信成为性能瓶颈。传统方案在跨节点传输时带宽利用率不足50%&#xff0c;延迟高达300μs以上。DeepSee…

多通道数据采集和信号生成的模块化仪器如何重构飞机电子可靠性测试体系?

飞机的核心电子系统包括发电与配电系统&#xff0c;飞机内部所有设备和系统之间的内部数据通信系统&#xff0c;以及用于外部通信的射频设备。其他所有航空电子元件都依赖这些关键总线进行电力传输或数据通信。在本文中&#xff0c;我们将了解模块化仪器&#xff08;无论是PCIe…

【Godot4.3】基于绘图函数的矢量蒙版效果与UV换算

概述 在设计圆角容器时突发奇想&#xff1a; 将圆角矩形的每个顶点坐标除以对应圆角矩形所在Rect2的size&#xff0c;就得到了顶点对应的UV坐标。然后使用draw_colored_polygon&#xff0c;便可以做到用图片填充圆角矩形的效果。而且这种计算的效果就是图片随着其填充的图像缩…

数据存储:一文掌握存储数据到MongoDB详解

文章目录 一、环境准备1.1 安装MongoDB1.2 安装Python MongoDB驱动 二、连接到MongoDB2.1 基本连接2.2 连接到MongoDB Atlas&#xff08;云服务&#xff09; 三、基本CRUD操作3.1 创建&#xff08;Create&#xff09;&#xff1a;插入数据3.2 读取&#xff08;Read&#xff09;…

算法教程:岛的最大面积

算法教程:岛的最大面积 我们将首先讨论问题和解决方案,然后使用可视化工具(上一篇博客中进行了介绍)来更好地理解搜索过程。 问题描述 我们将要演练的具体问题是问题 Leetcode:岛屿的最大面积。在 Leetcode 上找到的直接问题描述是: 给你一个 m x n 二进制矩阵网格。岛…

Scrapy:隧道代理中移除 Proxy-Authorization 的原理解析

隧道代理中移除 Proxy-Authorization 的原理解析 背景 在 Scrapy 的 HTTP 下载处理中&#xff0c;当使用隧道代理&#xff08;TunnelingAgent&#xff09;时&#xff0c;会移除请求头中的 Proxy-Authorization。这个操作看似简单&#xff0c;但背后有着重要的安全考虑和技术原…

大中型虚拟化园区网络设计

《大中型虚拟化园区网络设计》属于博主的“园区网”专栏&#xff0c;若想成为HCIE&#xff0c;对于园区网相关的知识需要非常了解&#xff0c;更多关于园区网的内容博主会更新在“园区网”专栏里&#xff0c;请持续关注&#xff01; 一.前言 华为云园区网络解决方案(简称Cloud…

sklearn中的决策树-分类树:剪枝参数

剪枝参数 在不加限制的情况下&#xff0c;一棵决策树会生长到衡量不纯度的指标最优&#xff0c;或者没有更多的特征可用为止。这样的决策树 往往会过拟合。为了让决策树有更好的泛化性&#xff0c;我们要对决策树进行剪枝。剪枝策略对决策树的影响巨大&#xff0c;正确的剪枝策…

几个api

几个api 原型链 可以阅读此文 Function instanceof Object // true Object instanceof Function // true Object.prototype.isPrototypeOf(Function) // true Function.prototype.isPrototypeOf(Object) // true Object.__proto__ Function.prototype // true Function.pro…

【Azure 架构师学习笔记】- Azure Databricks (12) -- Medallion Architecture简介

本文属于【Azure 架构师学习笔记】系列。 本文属于【Azure Databricks】系列。 接上文 【Azure 架构师学习笔记】- Azure Databricks (11) – UC搭建 前言 使用ADB 或者数据湖&#xff0c;基本上绕不开一个架构“Medallion”&#xff0c; 它使得数据管理更为简单有效。ADB 通过…

Android手机部署DeepSeek

1.概述 android手机端部署deepseek一般需要安装termux,ollama,deepseek三个大的步骤 原因分析&#xff1a;deepseek等大模型需要类似ollama的工具去运行。ollama有mac window和linux版本&#xff0c;无Android版本&#xff1b;termux是一个模拟linux环境的Android app&#x…

计算机科学技术领域的内卷现状与应对措施分析

计算机科学技术领域的内卷现状与应对措施分析 李升伟 整理 ### 计算机科学技术领域的内卷现状与应对措施分析 #### 一、内卷现状分析 1. **教育与升学内卷** 计算机科学与技术相关专业&#xff08;如计算机科学与技术、人工智能、大数据等&#xff09;已成为考研竞争最…

python-leetcode 45.二叉树转换为链表

题目&#xff1a; 给定二叉树的根节点root,请将它展开为一个单链表&#xff1a; 展开后的单链表应该使用同样的TreeNode,其中right子指针指向链表中的下一个节点&#xff0c;而左子指针始终为空 展开后的单链表应该与二叉树先序遍历顺序相同 方法一&#xff1a;二叉树的前序…

【leetcode hot 100 15】三数之和

一、两数之和的扩展 class Solution {public List<List<Integer>> threeSum(int[] nums) {// 将得到的结果存入Set中&#xff0c;保证不重复Set<List<Integer>> set new HashSet<>();// 模拟两数之和&#xff0c;作为第一个循环中的内容for(in…

设备健康管理系统在制造业的深度应用探索

引言 在制造业的数字化转型浪潮中&#xff0c;设备健康管理系统正逐渐成为企业提升竞争力的关键利器。随着工业 4.0 和智能制造概念的不断深入&#xff0c;制造业对设备的高效、稳定运行提出了更高要求。设备健康管理系统借助先进的传感器技术、物联网&#xff08;IoT&#xf…