inserting characters at the start and end of a string

前端 未结 7 1188
灰色年华
灰色年华 2020-12-02 14:06

I am new and trying to find a way to insert a number of L\'s at the beginning and end of a string. So if I have a string which says

\"where did I put my cupcake thi

相关标签:
7条回答
  • 2020-12-02 14:50

    Adding to C2H5OH's answer, in Python 3.6+ you can use format strings to make it a bit cleaner:

    s = "something about cupcakes"
    print(f"L{s}LL")
    
    0 讨论(0)
提交回复
热议问题