Replace One Line of Multiline String In Python? -


i have multi-line string in python, , want replace specific line number of it. have loop goes through each line , increments line number 1, do when reach line need replace? suggestions?

yourstring = yourstring.split("\n") yourstring[lineyouwant] = edit yourstring = "\n".join(yourstring) 

lineyouwant 0 indexed


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -