如何删除双字符串以使其仅作为第一个单词?

How can I remove a double string to have it only be the first word?

我有一个字符串是同一个词两次,即 "hihi"。如何删除第一个 'hi' 以便只存在第二个?

如果字符串总是double,你可以在中间拆分它。

str_1 = "hihi"

print(str_1[len(str_1)//2:])

除了显而易见的,还有正则表达式:

In [774]: re.sub(r'^(.*?)$', r'', "hihi")
Out[774]: 'hi'