Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

read a file in python

lines = []
with open('the-zen-of-python.txt') as f:
    lines = f.readlines()

count = 0
for line in lines:
    count += 1
    print(f'line {count}: {line}')    
Code language: JavaScript (javascript)
Source by www.pythontutorial.net #
 
PREVIOUS NEXT
Tagged: #read #file #python
ADD COMMENT
Topic
Name
1+4 =