Python的with open file as 自我了解解释

#!/usr/bin/env python
# -*- coding:utf-8 -*-
with open ('1.txt') as f1:
f1.line = f1.readlines()
print (f1.line)

with open('2.txt') as f2:
f2.line = f2.readlines()
print (f2.line)

#写在一块 中间用,分开,注意最后:结尾, 类似循环语句的结尾
with open ('1.txt') as f1,open('2.txt') as f2:
f1.line = f1.readlines()
f2.line = f2.readlines()
print (f1.line)
print (f2.line)
posted @ 2016-03-16 18:05  Tom-Li  阅读(627)  评论(0编辑  收藏  举报