通过本文主要向大家介绍了python字符串插入字符,python字符串方法,python中字符串的方法,python字符串处理,python 字符串等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
"".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 in Python 2.7:
from collections import OrderedDict
foo = "mppmt"
print "".join(OrderedDict.fromkeys(foo))
printing
mpt
</div>

