New course! Every coder should learn Generative AI!
Try a free lesson+ 1
what is the difference between read() and readlines()?
4 Answers
+ 2
Read method reads the whole file as a single string while readlines segregates each of the line in the file and you then can later on call them line by line.
0
Hamid Ashraf what if i used readline first then i used read()? will read() read all file include first line?
0
That depends on your code. If f is an open file you can apply any method in any sequence provided that you are saving their output in different variable.
0
Hamid Ashraf thank you :)