Python

    技术2024-11-06  6

    targetstr = "abcgbuvg"

    ####如果顺序不重要####

    #set() will create a set of unique letters in the string

    #"".join() will join the letters back to a string in arbitrary order

    "".join(set(targetstr))

    ####考虑顺序问题####

    from collections import OrderedDict

    "".join(OrderedDict.fromkeys(targetstr))

    Processed: 0.025, SQL: 9