The write method takes a single scalar argument and writes it to the file represented by the file object on which it operates. Note that, unlike the print command, the write method does not automatically append a newline character to its argument. One consequence of this is that you can safely write binary files, or files with embedded null characters, using the write method. If you are writing a binary file, remember to append a 'b' to the second argument of the open function as described in Section 5.4.
The writelines method accepts a list argument, and writes each element of the list to the specified file as if a call to the write method had been made; no newlines are added to the output.