I'm writing a series of SQL statements to a file using python. The template string looks like:
store_insert = '\tinsert stores (storenum, ...) values (\'%s\', ...)'
I'm writing to the file like so:
for line in source:
line = line.rstrip()
fields = line.split('\t')
script.write(store_insert % tuple(fields))
script.write(os.linesep)
However, in the resulting output, I see \r\r\n at the end of each line, rather than \r\n as I would expect. Why?
%
string formatting is now old; the preferred idiom isstr.format
=) – Ahner