您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

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

2025/12/25 2:03:23发布13次查看
代码如下:
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
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product