Ich hab ein paar Probleme mit writelines
So weit Ich weis kann damit mehrere Zeilen in eine Datei schreiben.
Das bekomme Ich aber nicht hin.
HILFE

Wenn das nicht hilft, solltest du uns mal dein Problem erklären .. oder zumindest erst mal nennen.Python Library Reference hat geschrieben:file.writelines(sequence)
Write a sequence of strings to the file. The sequence can be any iterable object producing strings, typically a list of strings. There is no return value. (The name is intended to match readlines(); writelines() does not add line separators.)
Code: Alles auswählen
test1 = "zwei"
test2 = "drei"
teste = test1 + test2
test = open("test.txt","w")
test.writelines(teste)
test.close()
Code: Alles auswählen
test1 = "zwei"
test2 = "drei"
teste = "%s%s" % (test1, test2)
with open("test.txt","w") as test:
test.write(teste)
Code: Alles auswählen
test1 = "zwei"
test2 = "drei"
teste = "%s%s" % (test1, test2)
with open("test.txt","w") as test:
test.write(teste)
Code: Alles auswählen
test1 = "zwei"
test2 = "drei"
teste = "%s\n%s" % (test1, test2)
with open("test.txt","w") as test:
test.write(teste)
Code: Alles auswählen
from __future__ import with_statement
with open('hu', 'w') as fp:
fp.writelines([('%s' % i) * i + '\n' for i in range(1, 6)])
Code: Alles auswählen
import os
test1 = "zwei%s" % os.linesep
test2 = "drei%s" % os.linesep
with open("test.txt","w") as test:
test.writelines([test1, test2])