python去重并從小到大排列,python實現列表去重改變順序_python實現文本去重且不打亂原本順序

 2023-12-25 阅读 31 评论 0

摘要:#####################################################################qq:316118740python去重并從小到大排列,#BLOG:http://hi.baidu.com/alalmn# python 讀取TXT到數組 列表去重,不打亂原來的順序# 剛學寫的不好請大家見諒Python 列表去重?####################

####################################################################

#qq:316118740

python去重并從小到大排列,#BLOG:http://hi.baidu.com/alalmn

# python 讀取TXT到數組 列表去重,不打亂原來的順序

# 剛學寫的不好請大家見諒

Python 列表去重?####################################################################

def open_txt(): #打開TXT文本寫入數組

try:

python如何刪除列表中相同的內容、infile = file('admin.txt', 'r')

xxx = file('admin.txt', 'r')

for xxx_line in xxx.readlines():

passlist.append(xxx_line)

xxx.close()

except:

return 0

def list_del(): #清空list列表

try:

i = 0 #得到list的第一個元素

while i < len(passlist):

del passlist[i]

del list_passwed[i]

except:

return 0

######################################

global passlist #聲明全局變量

passlist = [] #用戶名:anonymous 密碼為空

www_cj(www) #域名拆解

open_txt() #TXT導入數組

#passlist = list(set(passlist)) #python 列表去重

global list_passwed #列表去重,不打亂原來的順序

list_passwed=[]

for i in passlist:

if i not in list_passwed:

list_passwed.append(i)

###################################### 遍歷數組組合出 密碼

I1 = 0 #得到list的第一個元素

while I1 < len(list_passwed):

print "WWWWWWWWWWW",I1

if I1==len(list_passwed):

break #退出循環

I2 = 0 #得到list的第一個元素

while I2 < len(list_passwed):

print "1111:",list_passwed[I1],"2222:",list_passwed[I2]

I2 = I2 + 1 #二層

I1 = I1 + 1 #一層

######################################

本文實例講述了python讀取TXT到數組及列表去重后按原來順序排序的方法。分享給大家供大家參考。

本文原創發布php中文網,轉載請注明出處,感謝您的尊重!

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/1/194590.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息