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

首頁 > 編程 > Python > 正文

python去掉字符串中重復(fù)字符的方法

2019-11-25 18:30:11
字體:
供稿:網(wǎng)友

復(fù)制代碼 代碼如下:

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

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 堆龙德庆县| 阿荣旗| 宜川县| 建阳市| 巴东县| 五常市| 宁河县| 措美县| 兴化市| 青川县| 专栏| 南岸区| 广宗县| 宜都市| 江北区| 文登市| 上栗县| 天长市| 江都市| 林州市| 淮安市| 高邑县| 巴青县| 云和县| 镇坪县| 聊城市| 邵阳市| 汶川县| 定兴县| 齐齐哈尔市| 西贡区| 江华| 临猗县| 德清县| 徐州市| 凤庆县| 昌邑市| 宝鸡市| 花莲市| 铜山县| 呼玛县|