python去掉字符串中重复字符的方法
2014-02-27 00:00
771 查看
If order does not matter, you can use "".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
相关文章推荐
- python去掉字符串中重复字符的方法
- ASP.NET过滤重复字符与字符串数组去掉重复字符串几种方法
- 【python】去掉字符串中某个指定位置的字符的几种方法
- python3实现字符串的全排列的方法(无重复字符)
- python实现查找两个字符串中相同字符并输出的方法
- String.Join 和 Distinct 方法 去除字符串中重复字符
- 轻松python文本专题-单独处理字符串每个字符的方法汇总
- Python去掉字符串中空格的方法
- 字符串数组(String []) 去掉重复值的方法
- 去掉字符串中重复的字符 --- 华为笔试题
- Java实现去掉字符串重复字母的方法示例
- 去掉数组中重复元素以及字符串重复字符
- python 4-6 如何去掉字符串中不需要的字符strip('-+*')/lstrip()/rstrip()/切片分段+/replace/sub/translate
- 字符串操作(人民币转成大写/全角字符转半角字符/去掉字符串中重复的子字符串/过滤常见特殊字符/反过滤特殊字符/判断是不是合法手机/字符串匹配的算法)
- 轻松python文本专题-单独处理字符串每个字符的方法汇总
- JS使用正则表达式除去字符串中重复字符的方法
- 轻松python文本专题-单独处理字符串每个字符的方法汇总
- 字符串数组(String []) 去掉重复值的方法
- 字符串数组(String []) 去掉重复值的方法
- Python字符串逐字符或逐词反转方法