你还可以在Python 3+中使用这个函数来动态生成它:
def striken(text):
return ''.join(t+chr(822) for t in text)
示例输出
>>> def striken(text):
... return ''.join(t+chr(822) for t in text)
...
>>> striken("hello")
'h̶e̶l̶l̶o̶
>>> striken("hello darkness my old friend")
'h̶e̶l̶l̶o̶ ̶d̶a̶r̶k̶n̶e̶s̶s̶ ̶m̶y̶ ̶o̶l̶d̶ ̶f̶r̶i̶e̶n̶d̶'
此外,你也可以使用以下方法:
def striken(text):
return '\u0336'.join(text) + '\u0336'
如果你的文本真的很长,建议按照 @astroMonkey 的建议来提高速度。