python

python中用什么函数关闭文件

九三
278
2021-02-13 09:31:38
栏目: 编程语言

python中用什么函数关闭文件

在python中使用close函数关闭文件的方法

close函数是用于关闭一个已打开的文件。

close()函数语法:

fileObject.close(); #fileObject为文件对象

close()函数使用方法:

# 打开文件

fo = open("runoob.txt", "wb")

print "文件名为: ", fo.name

# 关闭文件

fo.close()

0
看了该问题的人还看了