Collection:
1list1=[1,3,4,6,7]2 #List Conversion Collection3list1=Set (List1)4 Print(List1)5 #Defining Collections6List2=set ([3,7,5,8])7 Print(Type (LIST2))8 #intersection9 Print(List1.intersection (list2))Ten Print(List1 &list2) One #and set A Print(List1.union (list2)) - Print(List1 |list2) - #Difference Set the Print(List1.difference (LIST2))#List1, there's list2. - Print(List2.difference (List1))#Liat2, there's List1. - Print(List1-list2) - #Symmetric difference Sets + Print(List1.symmetric_difference (list2)) - Print(list1 ^list2) + #judging subsets A Print(List1.issubset (list2)) at #judging the parent set - Print(List1.issuperset (list2)) - #determines if there is an intersection, and does not return true -List3=set ([2,5]) - Print(List1.isdisjoint (LIST3)) - #add an item to the collection inList1.add (123) - Print(List1) to #add multiple items in the collection +List1.update ([2,5]) - Print(List1) the #use Remove to specify that an item is deleted * #Pop Random Delete $ #Discard Delete no return value
File:
1 #Read Content2F=open ("Yesterday2","R", encoding="Utf-8") 3 #Write Content4F=open ("Yesterday2","a", encoding="Utf-8") 5 #Write Content6F=open ("Yesterday2","W", encoding="Utf-8")7 #back to where the file started.8 F.seek ()9 #locationTenF.tell ()
File modification:
1F=open ('A1','R', encoding="Utf-8")2F_new=open ('A2','W', encoding="Utf-8")3 forLineinchF:4 if "Nihaotopaz" inchLine :5Line2=line.replace ('Nihaotopaz','nihao!!! ')6F_new.write (line2)
Haproxy File Modification Exercises:
DAY3 haproxy configuration file modification