• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > python去掉字符串中重复字符的方法

python去掉字符串中重复字符的方法

作者: 字体:[增加 减小] 来源:互联网

通过本文主要向大家介绍了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>

</div>

您可能想查找下面的文章:

  • 再谈Python中的字符串与字符编码(推荐)
  • python实现查找两个字符串中相同字符并输出的方法
  • python实现查找两个字符串中相同字符并输出的方法
  • python清除字符串里非字母字符的方法
  • python清除字符串里非数字字符的方法
  • python过滤字符串中不属于指定集合中字符的类实例
  • Python检测字符串中是否包含某字符集合中的字符
  • Python字符串逐字符或逐词反转方法
  • python统计字符串中指定字符出现次数的方法
  • python去掉字符串中重复字符的方法

相关文章

  • Python程序中用csv模块来操作csv文件的基本使用教程
  • Python多进程同步Lock、Semaphore、Event实例
  • python实现在字符串中查找子字符串的方法
  • Pycharm学习教程(7)虚拟机VM的配置教程
  • Python里隐藏的“禅”
  • 使用wxpython实现的一个简单图片浏览器实例
  • Python多进程同步简单实现代码
  • Python合并字符串的3种方法
  • Python中多线程及程序锁浅析
  • 在Docker上开始部署Python应用的教程

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • python dict remove数组删除(del,pop)
    • 深入解析Python中的descriptor描述器的作用及用法
    • Python的Flask开发框架简单上手笔记
    • python操作MySQL数据库的方法分享
    • Python发送form-data请求及拼接form-data内容的方法
    • 解决python3 urllib中urlopen报错的问题
    • 使用Python读写及压缩和解压缩文件的示例
    • Python图算法实例分析
    • Python的subprocess模块总结
    • python实现汉诺塔递归算法经典案例

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有