Python-os-close
提供:Dev Guides
Python os.close()メソッド
説明
Pythonメソッド* close()*は、ファイル記述子_fd_に関連付けられたものを閉じます。
構文
以下は* close()*メソッドの構文です-
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!!"
上記のプログラムを実行すると、次の結果が生成されます-
Closed the file successfully!!