Timeline for answer to Writing string to a file on a new line every time by halfdan
Current License: CC BY-SA 3.0
Post Revisions
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 27, 2023 at 11:18 | comment | added | Alex Martian | Use '\\n' to write actual '\n' if needed. | |
| Nov 7, 2021 at 23:00 | comment | added | mckenzm | what if we need a callback? | |
| Dec 4, 2020 at 19:10 | comment | added | Timo | Or file.write(f'{var1}\n') with single quotation marks | |
| Jul 17, 2019 at 8:25 | comment | added | halfdan |
In newer versions of Python (3.6+) you can also just use f-strings: file.write(f"{var1}\n")
|
|
| Jul 17, 2019 at 2:57 | comment | added | Filipe | If you're using variables to compose the record, you can add + "\n" at the end, like fileLog.write(var1 + var2 + "\n"). | |
| Mar 24, 2017 at 20:00 | history | edited | James MV | CC BY-SA 3.0 |
Remove semi colon.
|
| May 27, 2010 at 4:49 | vote | accept | kaushik | ||
| May 27, 2010 at 3:59 | history | answered | halfdan | CC BY-SA 2.5 |