Avatar ·

Python中正确的换行方式

📁 列表, python, 示例

请教一下,有一个包含短语的列表,但这些短语很长,PEP8 会报错说行太长。

我使用 \ 符号来换行部分短语,但它会把所有空格也算进去。

示例:

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."",                 ""Текст любой, не важно, но после бэкслэша огромное \                 расстояние между словами. Как это исправить?""]print(*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. Текст л