I am newbie in Python facing a problem: How to insert some fields in already existing string?
For example, suppose I have read one line from any file which contains:
line = "Name Age Group Class Profession"
Now I have to insert 3rd Field(Group) 3 times more in the same line before Class field. It means the output line should be:
output_line = "Name Age Group Group Group Group Class Profession"
I can retrieve 3rd field easily (using split
method), but please let me know the easiest way of inserting into the string?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…