हिंदी

Explain the use of output function writelines() with an example.

Advertisements
Advertisements

प्रश्न

Explain the use of output function writelines() with an example.

कोड लेखन
स्पष्ट कीजिए
Advertisements

उत्तर

writelines(): Writes a sequence of strings. Newline characters must be supplied by the programmer.

lines = ["First line\n", "Second line\n"]
with open("data.txt", "w") as file:
    file.writelines(lines)
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 7: Data File Handling - EXERCISE [पृष्ठ १४५]

APPEARS IN

सीबीएसई Computer Science with Python [English] Class 12
अध्याय 7 Data File Handling
EXERCISE | Q 9. b. | पृष्ठ १४५
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×