Python方法close()关闭与文件描述符关联的fd。
os.close(fd);
fd - 这是文件的文件描述符。
以下示例显示close()方法的用法。
#!/usr/bin/python import os, sys # Open a file fd=os.open( "foo.txt", os.O_RDWR|os.O_CREAT ) # Write one string os.write(fd, "This is test") # Close opened file os.close( fd ) print "Closed the file successfully!!"
当无涯教程运行上面的程序时,它产生以下输出-
链接:https://www.learnfk.comhttps://www.learnfk.com/python/os-close.html
来源:LearnFk无涯教程网
Closed the file successfully!!
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)