Python reading text files

file = open("sample.txt", 'r')

while True:
    line = file.readline()
    if not line:
        break
    pass # do something

Reference: Reading text files

Homepage
Comments

Hide Comments