Korrekte Zeilenumbrüche in Python
📁 Liste, Python, Beispiel
Sagen Sie, es gibt eine Liste mit Phrasen, aber sie sind lang und pep8 beschwert sich über die Zeilenlänge.
Ich übertrage einen Teil der Phrase mit dem Symbol \, aber dann zählt es alle Leerzeichen mit.
Beispiel:
list_of_words = ["""The weather is good.""", """Hot dog is the best food, \ it would be a sure sign that it was still yummy.""", """The girls are beautiful.""", """Anyone doesn’t matter, but after backslashes a huge \ distance between words. How to fix it?"""] print(*list_of_words)Die Ausgabe:
The weather is good. Hot dog is the best food, it would be a sure sign that it was still yummy. The girls are beautiful. Anyone doesn’t matter, but after backslashes a huge distance between words. How to fix it?