В моем проекте у меня есть группа строк, которые считываются из файла. Большинство из них при печати в командной консоли превышают 80 символов и обертываются вокруг, выглядя уродливо.
Я хочу, чтобы Python читал строку, а затем проверяйте, имеет ли она более 75 символов. Если это так, разделите строку на несколько строк, а затем напечатайте один за другим в новой строке.
Я также хочу, чтобы это было умным, а не прекращением полных слов. т.е. "The quick brown <newline> fox..."
вместо "the quick bro<newline>wn fox..."
.
Я пробовал модифицировать аналогичный код, который усекает строку после заданной длины, но просто разбивает строку, а не помещает ее в новую строку.
Какие методы я могу использовать для этого?