User Tools

Site Tools


read_py_file

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
read_py_file [2018/05/02 20:46]
zeppo created
read_py_file [2018/05/02 20:50] (current)
zeppo
Line 1: Line 1:
-########################################​ +   ########################################​ 
-Save as readfile_1.py - works and removes blank lines +   ​Save as readfile_1.py - works and removes blank lines 
-############################################​ +   ​############################################​ 
-import os +   ​import os 
-f = open('​C:​\\temp\\one.txt',​ "​r"​) +   ​f = open('​C:​\\temp\\one.txt',​ "​r"​) 
-for line in f: +   ​for line in f: 
-   ​print(line.strip()) +      print(line.strip()) 
-f.close()+   f.close() 
 +    
 +   #######################################​ 
 +   the below is the same with explicit "​readline"​ 
 +   But does the same thing 
 +   #######################################​ 
 +   ​import os 
 +   f = open('​C:​\\temp\\one.txt',​ "​r"​) 
 +   for line in f.readlines():​ 
 +      ​print(line.strip()) 
 +   ​f.close() 
  
read_py_file.1525311975.txt.gz · Last modified: 2018/05/02 20:46 by zeppo