Python reads txt to array and list to sort by original order after heavy

Source: Internet
Author: User
Tags sort

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.