KnowledgeBoat Logo

Computer Science

Differentiate between write() and writelines().

Python File Handling

6 Likes

Answer

write()writelines()
The write() method is used to write a single string to a file.The writelines() method is used to write multiple strings to a file.
The write() method takes a string as an argument.The writelines() method takes an iterable object like lists, tuple, etc. containing strings as an argument.
The write() method returns the number of characters written on to the file.The writelines() method does not return the number of characters written in the file.

Answered By

4 Likes


Related Questions