查找字符串中的唯一字符

5年以前  |  阅读数:443 次  |  编程语言:Python 

此代码段可用于查找字符串中的所有唯一字符。

string = "abcbcabdb"   
unique = set(string)
new_string = ''.join(unique)
print(new_string) # abcd

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8