码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2016-03-16 19:11:30      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:

#!/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)

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

标签:

原文地址:http://www.cnblogs.com/tom-li/p/5284546.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!