擅长:python、mysql、java
<p>另一个选项是Python Regex:</p>
<pre class="lang-py prettyprint-override"><code>import re
content = "first line \nsecond line\nthird line\netc."
print(re.sub(r'^.{1,5}$', '', content, flags=re.MULTILINE))
</code></pre>
<p>结果:</p>
<pre><code>'first line \nsecond line\nthird line\n'
</code></pre>