
python学习
文章平均质量分 53
Elvira521yan
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
pydantic.BaseModel
id: intemail: strreturn vtry:print(e)# 输出: 1 validation error for UserWithCustomValidation# email# 输出: UserWithCustomValidation(id=2, username='user2', email='user2@example.com')Pydantic的BaseModel提供了一种高效且直观的方式来进行数据验证、解析和转换。原创 2025-05-13 14:13:47 · 303 阅读 · 0 评论 -
使用 type 函数动态创建一个类
使用 type 函数动态创建一个类原创 2025-05-12 10:27:34 · 257 阅读 · 0 评论 -
【协程coroutine】async & await
async用于定义异步函数。await在异步函数中等待另一个异步操作完成。使用 asyncio.run或 事件循环来调度执行协程。掌握async和await能大大提升你在处理 IO 密集型任务,如网络请求和文件操作时的代码效率和结构清晰度。原创 2025-05-07 15:51:13 · 297 阅读 · 0 评论 -
【python】asyncio
a Python library that provides support for asynchronous programming, enabling you to write code that performs non-blocking I/O operations. This can be useful for applications that need to handle many tasks concurrently, such as web servers, network clie原创 2025-05-06 17:21:48 · 635 阅读 · 0 评论 -
shutil.copy、shutil.copyfile、shutil.copy2的区别
shutil.copy、shutil.copyfile、shutil.copy2的区别原创 2022-09-05 14:56:54 · 7903 阅读 · 1 评论 -
PyCharm中Directory与Python package的区别
对于Python而言,有一点是要认识明确的,python作为一个相对而言轻量级的,易用的脚本语言(当然其功能并不仅限于此,在此只是讨论该特点),随着程序的增长,可能想要把它分成几个文件,以便逻辑更加清晰,更好维护,亦或想要在几个程序中均使用某个函数,而不必将其复制粘贴到所有程序中。为了支持这一点,Python有一种方法将定义函数放在一个文件中,并在脚本中使用它们,这样的文件叫做模块,一个模块中的定...转载 2018-05-23 09:33:05 · 1049 阅读 · 0 评论 -
【python】logging模块常用功能
logging 日志模块常用功能用于输出运行日志,可以设置输出日志的等级、日志保存路径、日志文件回滚等配置logging.basicConfig(level = logging.DEBUG,format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s')args:level:设置日志级别,默认为logging.WARN...原创 2019-03-17 22:06:23 · 302 阅读 · 0 评论