python去掉字符串中重復字符的方法
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
相關(guān)文章
在matlab中創(chuàng)建類似字典的數(shù)據(jù)結(jié)構(gòu)方式
這篇文章主要介紹了在matlab中創(chuàng)建類似字典的數(shù)據(jù)結(jié)構(gòu)方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-03-03python爬蟲之urllib庫常用方法用法總結(jié)大全
urllib是python自帶的請求庫,各種功能相比較之下也是比較完備的,下面這篇文章主要給大家介紹了關(guān)于python爬蟲之urllib庫常用方法用法的相關(guān)資料,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考下2018-11-11PyTorch中Tensor的數(shù)據(jù)類型和運算的使用
這篇文章主要介紹了PyTorch中Tensor的數(shù)據(jù)類型和運算的使用,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-09-09Selenium 模擬瀏覽器動態(tài)加載頁面的實現(xiàn)方法
這篇文章主要介紹了Selenium 模擬瀏覽器動態(tài)加載頁面的實現(xiàn)方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-05-05