标签:
参考:http://zhoutall.com/archives/325
开了文件就得关,
用 with as 就省了 finally
| try:    with open( "a.txt") as f :        do somethingexceptxxxError:    do something about exception | 
with-as表达式极大的简化了每次写finally的工作,这对保持代码的优雅性是有极大帮助的。
标签:
原文地址:http://www.cnblogs.com/pudding-ai/p/5314788.html