国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

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

2020-02-23 05:11:04
字體:
來源:轉載
供稿:網友

代碼如下:
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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 淳安县| 兰州市| 宁化县| 中牟县| 白朗县| 五台县| 周至县| 通许县| 阳新县| 新乡县| 江门市| 合阳县| 禄劝| 伽师县| 靖西县| 芜湖市| 札达县| 安平县| 光山县| 澳门| 林甸县| 赤城县| 福建省| 秦皇岛市| 新化县| 汽车| 内乡县| 嘉鱼县| 永福县| 普安县| 冕宁县| 海阳市| 昌宁县| 榆树市| 望谟县| 佛学| 广水市| 民丰县| 平利县| 新郑市| 资溪县|