English

Differentiate between write() and writelines(). - Computer Science (Python)

Advertisements
Advertisements

Question

Differentiate between write() and writelines().

Distinguish Between

Solution

  • write() method takes a string as an argument and writes it to the text file.
  • writelines() method is used to write multiple strings to a file. We need to pass an iterable object like lists, tuple etc. containing strings to writelines() method.
shaalaa.com
Writing to a Text File
  Is there an error in this question or solution?
Chapter 2: File Handling in Python - Exercise [Page 37]

APPEARS IN

NCERT Computer Science [English] Class 12
Chapter 2 File Handling in Python
Exercise | Q 1. c) | Page 37
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×