Answers for "read line"

2

readline in a file

myfile = open("demo.txt", "r")
myline = myfile.readline()
while myline:
    print(myline)
    myline = myfile.readline()
myfile.close()
Posted by: Guest on June-24-2021
2

python read lines

f = open("filename")
lines = f.readlines()
Posted by: Guest on November-16-2020
0

how to use readline in python

myFile = open("test.txt,"r")
print(myFile.readline(0))# print the first line of the text file
print(myFile.readline(1))# print the second line of the text file
print(myFile.readline(2))# print the tird line of the text file
# ect..
# you might need to use MyFile.seek(0) after reading
Posted by: Guest on August-02-2021
0

Readline Python

f = open("C:\Users\Andreea Pantus\Desktop\An 2, Semestrul 2\Inteligenta artificiala, machine learning\ai-unibuc-24-22-2021\train.txt", "r")
print(f.readline())
Posted by: Guest on March-26-2021

Python Answers by Framework

Browse Popular Code Answers by Language