<p>您可以使用<a href="http://docs.python.org/2/library/textwrap.html" rel="nofollow">^{<cd1>}</a>模块:</p>
<pre><code>>>> import textwrap
>>> strs="Ichg_UNBUNOA3 14 2090100000015 14 1304221445000001 MSG_BGM380 610809 9 NA MSG_DTM13720130422 102 Grp1_RFFON test EDI Grp2_NADBY"
#textwrap.fill(strs,640) appends a newline ("\n") after every 640 characters
#use "\r\n".join(textwrap.wrap(strs, 640)) if you want '\r\n' instead of '\n' as newline
>>> new_strs=textwrap.fill(strs,640)
>>> for line in new_strs.splitlines():
print " ".join(line.split())
...
Ichg_UNBUNOA3 14 2090100000015 14 1304221445000001
MSG_BGM380 610809 9 NA
MSG_DTM13720130422 102
Grp1_RFFON test EDI
Grp2_NADBY
</code></pre>