共有 8 篇文章
2024-08-26
列表生成式(List Comprehensions)
2024-08-26 ~ 2024-08-26
列表生成式(List Comprehension)是 Python 中一种生成列表的方式。它允许你使用单行语法,基于已有的序列(如列表、元组、字符串等)来生成一个新的列表,且通
2024-08-10
Codewars
2024-08-10 ~ 2024-08-29
Data Structure Buffer Traffic light Description https://www.codewars.com/kata/58649884a1659ed6cb000072/ You’re writing code to control your town’s traffic lights. You need a function to handle each change from green, to yellow, to red, and then to green again. Complete the function that takes a string as an argument representing the current state of the light and returns a string representing the state the light should change to. For example, when the input is green, output should be yellow. def update_light(current): pass Solutions Ver
2024-04-16
Python 对象框架
2024-04-16 ~ 2024-08-27
想象你走进一家星巴克咖啡店。这里有许多不同种类的咖啡杯,每个咖啡杯都具有不同的特性。例如: 容量:有小杯(Tall)、中杯(Grande)、大杯(Venti)等。
2024-04-11
Python 中的异常处理
2024-04-11 ~ 2024-04-17
在我们的日常生活中,灵活应对突发状况是常态。比如说,在家炒菜时,火候的掌控至关重要。如果火太大,菜可能会糊;火太小,则菜可能生熟不均。为了避免这些情况,我们会经
2024-04-09
理解 Python 函数不同类型的参数及其使用
2024-04-09 ~ 2024-04-12
参数类型 Python 函数的参数类型主要有以下几种:位置参数、默认参数、关键字参数和可变参数。 位置参数(Positional arguments): 位置参数是最常见的参数类型
2024-04-09
理解 Python 中的 `if __name__ == "__main__"` 用法及其重要性
2024-04-09 ~ 2024-08-16
在 Python 中,if name == "main": 是一个常用的代码片段,用来判断当前脚本是否被直接运行而非被导入到其他脚本中。name 是一个内置变量1,如果模块被直接执行,__name
2024-02-22
Initializing a project with Poetry and VS Code editor
2024-02-22 ~ 2024-04-12
初始化项目使用到的工具如下: Poetry: 依赖管理 VS Code:代码编辑 Pytest:代码测试 Windows Terminal:执行相关命令,或者使用 VS Code 内嵌的 Terminal(在 VS Code 中按
2024-02-08
基于 pyenv-win 和 Poetry 构建 Python 开发环境
2024-02-08 ~ 2024-04-12
简介 构建和维护一个高效、可靠的 Python 开发环境是至关重要的。为了实现这一目标,开发者可以选择多种工具来搭建自己的开发环境,包括但不限于 virtualenv、venv、