If order does not matter, you can use
 
foo = "mppmt"
"".join(set(foo))

 


set() will create a set of unique letters in the string, and "".join() will join the letters back to a string in arbitrary order.

If order does matter, you can use collections.OrderedDict:
from collections import OrderedDict
print "".join(OrderedDict.fromkeys(foo))
mpt

 

 

相关文章:

  • 2021-07-16
  • 2021-12-18
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-26
  • 2022-03-08
  • 2022-12-23
  • 2022-01-01
相关资源
相似解决方案