相关疑难解决方法(0)

包装文本文件,以便每行包含最多80个字符

是否有更好的方法来解决这个问题,最好不要通过模块.

问题是:

文字处理.您厌倦了在电子邮件包装上看到行,因为人们为您的邮件阅读器应用程序键入的行太长.创建一个程序来扫描长度超过80个字符的所有行的文本文件.对于每个违规行,找到80个字符前最接近的单词并在那里打破该行,将剩余的文本插入下一行(并将下一行向下推一行).完成后,不应有超过80个字符的行.

让9-16.txt的内容是:

Text Processing. You are tired of seeing lines on your e-mail wrap because people type lines that are too long for your mail reader application. Create a program to scan a text file for all lines longer than 80 characters. For each of the offending lines, find the closest word before 80 characters and break the line there, inserting the remaining text to the next line (and pushing the previous next line down one). When you …
Run Code Online (Sandbox Code Playgroud)

python string python-3.x

-1
推荐指数
1
解决办法
2121
查看次数

标签 统计

python ×1

python-3.x ×1

string ×1