python 示例_带有示例的Python File close()方法
python 示例
文件close()方法 (File close() Method)
close() method is an inbuilt method in Python, it is used to flush and close the IO object (file). If we close a closed file it has no effect.
close()方法是Python中的内置方法,用于刷新和关闭IO对象(文件)。 如果我们关闭已关闭的文件,则没有任何效果。
Syntax:
句法:
file_object.close()
Parameter(s):
参数:
It does not accept any parameter.
它不接受任何参数。
Return value:
返回值:
The return type of this method is <class 'NoneType'>, it returns nothing.
此方法的返回类型为<class'NoneType'> ,它什么也不返回。
Example 1:
范例1:
# Python File close() Method with Example
# opening a file in write mode
f = open("Hello.txt", "w")
print("file opened...")
print(f) # prints file details
# closing the file
f.close()
print("file closed...")
Output
输出量
file opened...
<_io.TextIOWrapper name='Hello.txt' mode='w' encoding='UTF-8'>
file closed...
Example 2:
范例2:
# Python File close() Method with Example
# opening a file in write mode
f = open("Hello.txt", "w")
print("file opened...")
# closing the file
f.close()
# closing a closed file
f.close()
print("file closed...")
Output
输出量
file opened...
file closed...
翻译自: https://www.includehelp.com/python/file-close-method-with-example.aspx
python 示例
python 示例_带有示例的Python File close()方法相关推荐
- python 示例_带有示例的Python File write()方法
python 示例 文件write()方法 (File write() Method) write() method is an inbuilt method in Python, it is use ...
- python 示例_带有示例的Python File read()方法
python 示例 文件read()方法 (File read() Method) read() method is an inbuilt method in Python, it is used t ...
- python示例_带有示例的Python功能指南
python示例 Python函数简介 (Introduction to Functions in Python) A function allows you to define a reusable ...
- python 示例_带有示例的Python文件关闭属性
python 示例 文件关闭属性 (File closed Property) closed Property is an inbuilt property of File object (IO ob ...
- python 示例_带有示例的Python字典popitem()方法
python 示例 字典popitem()方法 (Dictionary popitem() Method) popitem() method is used to remove random/last ...
- python 示例_带有示例的Python列表remove()方法
python 示例 列出remove()方法 (List remove() Method) remove() method is used to remove the first occurrence ...
- lock_sh 示例_带有示例的Python date __str __()方法
lock_sh 示例 Python date .__ str __()方法 (Python date.__str__() Method) date.__str__() method is used t ...
- python 示例_带有示例的Python date timetuple()方法
python 示例 Python date.timetuple()方法 (Python date.timetuple() Method) date.timetuple() method is used ...
- python 示例_带有示例的Python date isocalendar()方法
python 示例 Python date.isocalendar()方法 (Python date.isocalendar() Method) date.isocalendar() method i ...
最新文章
- 10个你必须知道的jQueryMobile代码片段(转)
- openssl加密http网站过程1
- 推荐一个不错的 Chrome 插件,百变皮肤,还可以去广告
- Java 8:将匿名类转换为Lambda表达式
- Solr空间搜索原理分析与实践
- 如何在开源社区贡献代码_在社区支持大量涌现之后,Biicode便开始开源
- SDN第5次上机作业
- 全国院线总票房破 50 亿!影院复工后,哪些电影最受欢迎?
- “迷失自我”,请记住下面5个网站,让你受益终身
- vs2015离线安装QT的vsix工具
- java poi 自动行高_Java POI Excel 行高自适应
- 2021年团体程序设计天梯赛题解
- java毕业生设计二手物品交易系统计算机源码+系统+mysql+调试部署+lw
- hp计算机如何重装win7,惠普笔记本重装Win7系统过程详解
- 1.01_AFNetworking(4.0.1)源码分析(一)
- 从来没有那么渴望顶端的风景过
- 文件夹里子文件夹快速重命名编号技巧
- {魔兽编辑器学习笔记} 一 安装编辑器、创建地图
- Shell教程(四)--输出的格式化
- 什么时候需要进行信号完整性分析?
热门文章
- matlab中如何调用gpu进行并行计算_极致安卓-Termux/Aid learning开启WebGL手机GPU并行计算...
- mysql怎么显示结果窗口_mysql8中窗口函数
- gcc参数 -i, -L, -l, -include
- 计算机组装过程英文版,计算机组装与维护试题及答案(国外英文资料).doc
- mysql ubuntu 17.04_1、mysql 5.7 ubuntu17.04
- python 除数不能为零的报错有哪些_【社区精选40】Python错误处理及代码调试方法(文末赠书中奖名单)...
- teamviewer类似软件_TeamViewer系统后台被黑客组织APT攻破,请注意防范
- python人脸识别源码_Python 抖音机器人,让你找到漂亮小姐姐
- 看懂架构设计中的服务隔离
- 面向对象、继承、抽象方法重载知识点整理