首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏小徐学爬虫

    从文本文件中读取博客数据并将其提取到文件中

    不要使用f=file("data.txt","wt"),而是使用更现代的with-statement语法(如上所示)。

    3.9K10编辑于 2024-06-11
  • 来自专栏量化投资与机器学习

    作为Python中级程序员,有句话不知当讲不当讲 ( ̄へ ̄)

    ▍__enter__ () 在进入with-statement主体之前调用 返回绑定到变量的值 可以返回任何类型的值 通常返回上下文管理器本身 ▍__exit__() 当语句体退出时调用 __exit

    1.5K20发布于 2019-05-16
  • 来自专栏Java项目实战

    什么是Python中的上下文管理器(context manager)?如何使用上下文管理器?

    参考文献 contextlib — Utilities for with-statement contexts - Python 「Python进阶 #1」上下文管理器Context Manager -

    3.8K30编辑于 2023-08-03
  • 来自专栏高渡号外

    夯实Python基础(7)

    内建对象 __main__ --- 顶层脚本环境 warnings --- Warning control dataclasses --- 数据类 contextlib --- Utilities for with-statement

    81730发布于 2020-09-22
  • 来自专栏小白维基

    WeeklyPEP-2-PEP343-with 语句-overview

    fact * sign # The "+s" rounds back to the original precision, # so this must be outside the with-statement

    92430编辑于 2022-04-02
  • 来自专栏Python无止境

    Python 的上下文管理器是怎么设计的?

    fact * sign # The "+s" rounds back to the original precision, # so this must be outside the with-statement

    94200发布于 2021-07-14
领券