This article describes the way Python reads txt to array and list to sort by the original order. Share to everyone for your reference. as follows:
?
43####################################################################
# python reads txt to array list to go heavy, do not disturb original order
# just learn to write well please forgive me
####################################################################
Def open_txt (): #打开TXT文本写入数组
Try
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 password is empty
WWW_CJ (WWW) #域名拆解
Open_txt () #TXT导入数组
#passlist = List (set (passlist)) #python listing to weight
Global list_passwed #列表去重, do not disturb the original order
List_passwed=[]
For I in Passlist:
If I not in list_passwed:
List_passwed.append (i)
###################################### traversal array combination out password
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 #一层
I hope this article will help you with your Python programming.