Python: Create strikethrough / strikeout / overstrike string type

后端 未结 3 1661
灰色年华
灰色年华 2021-01-02 21:46

I would appreciate some help in creating a function that iterates through a string and combines each character with a strikethrough character (\\u0336). With the output bein

3条回答
  •  天涯浪人
    2021-01-02 22:21

    How about:

    from itertools import repeat, chain
    
    ''.join(chain.from_iterable(zip(text, repeat('\u0336'))))
    

    or even more simply,

    '\u0336'.join(text) + '\u0336'
    

提交回复
热议问题