Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor sagars's Avatar
    Join Date
    Nov 2006
    Location
    Pune, india
    Posts
    186
    hi

    what should be the difference in output of write and writelines command for writting data in a file???

    thnks

  2. #2
    Nokia Developer Moderator bogdan.galiceanu's Avatar
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471
    I really don't think there's difference in output, just that using write() you can write a string, using writelines() you can write a list of strings.

    For example:
    Code:
    f=file("C:\\a.txt", "w")
    f.write("some text")
    f.close()
    
    #This will write the string "some text" in the file
    #Trying to write a sequence of strings like this will result in an error
    Code:
    strings=["word1","some other word","bla"]
    
    f=file("C:\\a.txt", "w")
    f.write(strings)
    f.close()

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved