Python,拆分字符串

Mat*_*ney 4 python string split

我有一个大的字符串文本文件,我想每117个字符拆分字符串并将下一个117个字符放在换行符上,依此类推,直到文件结束.

我试过这个:`s ="""我出于可见性原因删除了字符串"""space ="""

"""file = open('testoutput.txt','w')而s:print s [:10] output = output + s +""""

"""
s = s[10:]
Run Code Online (Sandbox Code Playgroud)

file.write(output)file.close()print"Done"`

但有一个问题,文件中的最终输出看起来像这个级联:`这[SHIFT] r [BACKSPACE]分子及其后代av [BACKSPACE] [BACKSPACE]因突变而变化

T]r[BACKSPACE]molecule and its descendants would av[BACKSPACE][BACKSPACE]vary because of mutations



ACE]molecule and its descendants would av[BACKSPACE][BACKSPACE]vary because of mutations



le and its descendants would av[BACKSPACE][BACKSPACE]vary because of mutations



 descendants would av[BACKSPACE][BACKSPACE]vary because of mutations



ts would av[BACKSPACE][BACKSPACE]vary because of mutations



v[BACKSPACE][BACKSPACE]vary because of mutations



E][BACKSPACE]vary because of mutations



CE]vary because of mutations



cause of mutations



utations
Run Code Online (Sandbox Code Playgroud)

`

Mar*_*tos 6

while s:
    print s[:117]
    s = s[117:]
Run Code Online (Sandbox Code Playgroud)