返回顶部

收藏

Closing Files

更多
# Open files consume system resources, and depending on the file mode, 
# other programs may not be able to access them. 

# It's important to close files as soon as you're finished with them, as shown in 
# 

f = open('/music/_singles/kairo.mp3', 'rb')        

print f.closed                                     

f.close()                                          
print f 

print f.closed                                     

# The closed attribute of a file object indicates whether the object has 
# a file open or not. In this case, the file is still open (closed is False).

标签:Python,File

收藏

0人收藏

支持

0

反对

0

发表评论