mutapath.Path.write_lines

Path.write_lines(lines, encoding=None, errors='strict', linesep='\n', append=False)[source]

Write the given lines of text to this file.

By default this overwrites any existing file at this path.

This puts a platform-specific newline sequence on every line. See linesep below.

lines - A list of strings.

encoding - A Unicode encoding to use. This applies only if

lines contains any Unicode strings.

errors - How to handle errors in Unicode encoding. This

also applies only to Unicode strings.

linesep - The desired line-ending. This line-ending is

applied to every line. If a line already has any standard line ending ('\r', '\n', '\r\n', u'\x85', u'\r\x85', u'\u2028'), that will be stripped off and this will be used instead. The default is os.linesep, which is platform-dependent ('\r\n' on Windows, '\n' on Unix, etc.). Specify None to write the lines as-is, like file.writelines().

Use the keyword argument append=True to append lines to the file. The default is to overwrite the file.

Warning

When you use this with Unicode data, if the encoding of the existing data in the file is different from the encoding you specify with the encoding= parameter, the result is mixed-encoding data, which can really confuse someone trying to read the file later.