当前位置: 代码迷 >> 综合 >> python file flash close
  详细解决方案

python file flash close

热度:104   发布时间:2023-10-10 22:13:40.0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2020/12/13 20:51
# @Author  : flyx
# @Site    : 
# @File    : demo7.py
# @Software: PyCharm
file = open('d.txt','a')
file.write('hello')
file.flush()
file.write('world')
file.close() # 会写入 hello world# file = open('d.txt','a')
# file.write('hello')
# file.close()
# file.write('world')
# file.close() # 会抛异常

 

  相关解决方案