zoukankan      html  css  js  c++  java
  • Case Closed?

    Finally, we'll want a way to test whether a file we've opened is closed. Sometimes we'll have a lot of file objects open, and if we're not careful, they won't all be closed. How can we test this?

    f = open("bg.txt")
    f.closed
    # False
    f.close()
    f.closed
    # True
    

    Python file objects have a closed attribute which is True when the file is closed and False otherwise.

    By checking file_object.closed, we'll know whether our file is closed and can call close() on it if it's still open.

  • 相关阅读:
    mysql基础
    协程
    锁与队列
    线程练习
    线程
    并发编程
    进程
    操作系统发展史
    第六周----例行报告
    附加题找bug
  • 原文地址:https://www.cnblogs.com/yaos/p/14014373.html
Copyright © 2011-2022 走看看