如何使用 Python 从字符串中删除重复字符?例如,假设我有一个字符串:
foo = "SSYYNNOOPPSSIISS"
如何制作字符串:
foo = SYNOPSIS
我是 python 新手,我已经厌倦了,它正在工作。我知道有一种聪明和最好的方法来做到这一点..只有经验才能证明这一点..
def RemoveDupliChar(Word):
        NewWord = " "
        index = 0
        for char in Word:
                if char != NewWord[index]:
                        NewWord += char
                        index += 1
        print(NewWord.strip()) 
注意:顺序很重要,这个问题与这个问题不同。