标签:
简单的说,
with open(filepath, ‘wb‘) as file:
file.write("something")
等价于:
file = open(filepath)
try:
file.write("something", ‘wb‘)
finally:
file.close()
总的来说with... as包含一个错误处理和一个文件关闭功能!
标签:
原文地址:http://www.cnblogs.com/yrqiang/p/5295371.html