Ich habe einen großen Textblock. Es hat Zeilenumbrüche, aber da die Zeilen trotz der Zeilenumbrüche immer noch zu lang sind, wird es in die nächste Zeile umgebrochen. Da bei allen anderen Skriptfunktionen alle Zeilen um ein Leerzeichen eingerückt sind, möchte ich, dass dies zutrifft. Ich verstehe, dass wenn ich nur eine Zeile drucke, kann ich einfach ein Leerzeichen einfügen, und wenn ich nach einem Zeilenumbruch, die in eine Zeile passen, einrücken möchte, kann ich einfach \n
mit einem Leerzeichen nach einfügen.Einrücken auf neue Zeilen in der Konsole
Wie würde ich jede Zeile in einem Textblock einfügen? z:
text = """This is a block of text. It keeps going on and on and on. It has some line breaks \n but mostly just keeps going on without breaks. The lines are sometimes too long, so they wrap to the next line, but they don't indent. I need to fix this"""
das wäre drucken, wie:
>>> print(text)
This is a block of text. It keeps going on
and on and on. It has some line breaks
but mostly just keeps going on without
breaks. The lines are sometimes too long,
so they wrap to the next line, but they
don't indent. I need to fix this
Ich schließe nicht importieren oder obere – user6896502
@NateHailfire, welche Version von Python sind Sie? – blackpen