开发者

Replace with newline python

I have a string

a=">NKMFFALGLLGDGVIGALDTVVSSMGAVGASGLS"

I want print a as

">
NKMFFALGLLGDGVIGALDTVVSSMGAVGASGLS"

I did a=a.replace(">","> \n") but it doesn开发者_高级运维't work. Where am I going wrong?


One thing is the internal representation of the string:

>>> a=">NKMFFALGLLGDGVIGALDTVVSSMGAVGASGLS"
>>> a.replace(">","> \n")
'> \nNKMFFALGLLGDGVIGALDTVVSSMGAVGASGLS'

another one is how it will be shown on screen:

>>> print(a.replace(">","> \n"))
> 
NKMFFALGLLGDGVIGALDTVVSSMGAVGASGLS
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜