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

[Python] Read from a File in Python

时间:2020-05-13 20:31:51      阅读:61      评论:0      收藏:0      [点我收藏+]

标签:with   The   term   ESS   end   cti   txt   span   bsp   

Using the open function, and the as and with keywords, we‘ll open up and read from a file. At the end of this lesson, you will be able to loop through the lines of text in a file, process the text in Python, and then print them to the terminal.

 

with open("input.txt") as text:
    for line in text:
        print("-------")
        print(line)

 

[Python] Read from a File in Python

标签:with   The   term   ESS   end   cti   txt   span   bsp   

原文地址:https://www.cnblogs.com/Answer1215/p/12884265.html

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