The examples in this article describe how Python reads txt to arrays and lists to be sorted in the original order. Share to everyone for your reference. Specific as follows:
##################################################################### python read txt to array list to go heavy, do not disturb the original order # just learn to write bad please forgive US # # ################################################################# #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 0def List_del (): #清空list列表 try:i = 0 #得到list的第一个元素 while I < Len (passlist): de L Passlist[i] del List_passwed[i] except:return 0###################################### global passlist #声明全局变 Volume passlist = [] #用户名: Anonymous password is empty www_cj (www) #域名拆解 open_txt () #TXT导入数组 #passlist = List (set (passlist)) #python column Table to go to the global list_passwed #列表去重, do not disrupt the original order list_passwed=[] for i in the passlist:if I not in list_passwed:list_passwe D.append (i) ###################################### traversal array combination out password I1 = 0 #得到list的第一个元素 while I1 < Len (list_passwed): P Rint "Wwwwwwwwwww", I1 if I1==leN (list_passwed): break #退出循环 I2 = 0 #得到list的第一个元素 while I2 < Len (list_passwed): print "1111:", List_pass WED[I1], "2222:", list_passwed[i2] I2 = I2 + 1 #二层 I1 = I1 + 1 #一层
Hopefully this article will help you with Python programming.