- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the differences between readline() and readlines() in Selenium with python?
The differences between readline() and readlines() methods are listed below.
readlines()
This method will read the entire content of the file at a time.
This method reads all the file content and stores it in the list.
This method reads up to the end of the line with readline () and returns a list.
readline()
This method will read one line in a file.
A new line character is left at the string end and is ignored for the last line provided the file does not finish in a new line.
This method reads up to the end of the line with readline() and returns a list.
Example
Code Implementation with readline()
#open the file for read operation fl = open('pythonfile.txt') # reads line by line ln = fl.readline() while ln!= "": print(ln) ln = fl.readline() #close the file fl.close()
Code Implementation with readlines()
#open the file for read operation fl = open('pythonfile.txt') # reads line by line and stores them in list for ln in fl.readlines(): print(ln) #close the file fl.close()
- Related Articles
- What are the differences between xpath and css in Selenium with python?
- What are the differences between implicit and explicit waits in Selenium with python?
- What are the differences between close() and quit() methods in Selenium with python?
- What are the differences between switch_to_default_content() and switch_to.parent_frame() methods in Selenium with python?
- What are the differences between current_window_handle and window_handles methods in Selenium with python?
- What are the differences between Python and an Anaconda?
- Differences Between Selenium and Cucumber
- What are the differences and similarities between tuples and lists in Python?
- What is the difference between Read() and ReadLine() methods in C#?
- What are assertions in Selenium with python?
- What are the differences between json and simplejson Python modules?
- What are the differences in between python 2.x and python 3.x versions?
- What is the difference between Read(), ReadKey() and ReadLine() methods in C#?
- What are the differences between group and layer in KineticJs with HTML?
- What are ActionChains class in Selenium with python?

Advertisements