Regular expressionsMeta-character quantifier (?)Metacharacters:.\w \d \s \w \d \s\ t \ \b() |[] [^]^ $Quantifiers:* + ?{n}, {n,}, {n,m}Re moduleHow to invoke the RE moduleFind: FindAll search match FinditerSplit and replace: Split Sub SubnCompile: Compile Save timeHow many places is the RE module used in?Quantifier: Indicates a match 0 or 1 timesAfter the quantifier: is the sign of the lazy matchGroup naming: (? pFindall/split Ungroup Priority: (?: Regular expression)
First, create a collection1. Featuresto store different elementsDisorderedImmutable types (numbers, strings, tuples)2. Create a CollectionS=set (' Hello ')Print (s)S=set ([' Alex ', ' Alex ', ' SB '])Print (s)s={1,2,3,4,5,6}3. Basic usage of sets(1) AddS.add (' s ')(2) ClearS.clear ()(3) CopyS.copy ()(4) DeleteRemove () Specifies to delete an element if the delete element does not exist then an errorDiscard (' sbbbb ') delete element not present no er
NodeListThe NodeList instance object is a class array object whose members are node objects, including the ChildNodes and Queryselectorall () method return valuesA dynamic collection is a change in the DOM structure that can be automatically reflected in the saved objectStaticNote NodeList are not all dynamic collections, where the Queryselectorall () return value is a static collection nodestaticlistArraySince nodelist is a class array object and not
The use of Java collection classes can be said to be ubiquitous, the total we can be divided into three chunks, respectively, from the collection interface extension of the list, set and the form of key-value pairs to store the map type collection. Many situations require that we iterate through the elements in the collection and do the appropriate processing. The following is a summary of the traversal of various types of collections, with regard to
1. Counter (counter)Counter is a dictionary method used to track the number of occurrences of a value, with all the functions and functions of a dictionary.>>> fromCollectionsImportCounter>>> D2 =Count>>> D2 = Counter ('abbcccddd')#Count of Values>>>Print(D2) Counter ({'D': 3,'C': 3,'b': 2,'a': 1})>>>Print(Type (D2))class 'collections. Counter'>>>> D2 = Counter ('abbcccddd')>>> forIinchD2.elements ():#count Element iterator...Print(i) ... bbadddccc>>>
Ever since JDK 1.2 collections are being widely used to store data in our programs. These Collection classes are used to store data which are shared by diferrent threads. Hence come the problem of which collection are. i.e. Operations on these collection classes are synchronized.If a collection class is isn't thread-safe and if we intend to use it in our multithreaded program, then we need to explicit Ely synchronize them. (or apply a wrapper class)So
The collections class contains a number of other useful utilities (such as Table II):Enumeration (Collection) produces the original style enumeration (enum) for the argumentMax (Collection), Min (Collection) produces the largest or smallest element in a natural comparison of objects within a set in an argumentMax (Collection,comparator), Min (collection,comparator) produces the largest or smallest element in a set with a comparerncopies (int n, Object
Since collections are a tool that we often use, a collection library is essential and should be easily reused. In this way, we can easily take various collections and insert them into our programs. Java provides such a library, although it appears to be very limited in Java 1.0 and 1.1 (the Java 1.2 Collection library is undoubtedly a masterpiece).
1. Next-tracing modelling and template/versatilityTo make
Python standard library notes (4)-collections module, pythoncollections
This module provides several very useful Python container types1. Container
Name
Function Description
OrderedDict
Dict that maintains the key Insertion Sequence
Namedtuple
Generate a tuple subclass that can access element content by name
Counter
Counter, mainly used to count
Deque
Similar to a list container, you can
collections are created separately, and the document is inserted. Delete > Db.blogs.remove () // Delete all documents in the collection.
> Db.blogs.remove ({"title": "Hello!"}) // deletes the document for the specified condition, and the current statement deletes "title" as "Hello!" The document. Two, set A collection is a set of documents that corresponds to a data table in a relational database. Dynamic mode The collection is in dynamic
1Import java.util.*; Public classaslist{ Public Static voidMain (String args[]) {//int arr[] = {1,2,3,4,45}; //list//List.add ("QQ"); Cannot be added here, because the length of the array is fixed//integer[] nums = {2,4,5,2}; //list//if the element in the array is an object, then the elements in the array go directly to the elements in the collection when they become collections//if the element in the array is the base data type, the array will be pre
contains a collection and a collectionBetweenthe relationship, also calledSubsetrelationships. Basic meaningis near the same as implication, implication, inclusion,Relationshipadjectives. the inclusions between elements and collections are called elements belonging to the collectionExample a={1,2},b={1,2,3} then 1∈a,2∈a,3∈b belongs to the relationship between the element and the set, for example, element a belongs to collection A, and a∈a belongs to t
This module implements a number of classes, which are very flexible. Can be used to replace Python's built-in dict, list, tuple, set type. And some features are not available for these built-in types.On the network to find some information, focusing on the collections module deque, Counter, Defaultdict class1. Class DequeSimilar to Python's built-in list, but it's a two-way list. Can be manipulated at any endHelp (Collections.deque)Class Deque (__buil
dictionaryKey does not exist, just addKey exists, overwriting the value corresponding to the existing keyIn-place modificationDictionary DeletePop (key[, default])Key exists, removes it, and returns its valueKey does not exist, returns the given defaultDefault is not set, key does not exist throw Keyerror exceptionPopitem ()Removes and returns an arbitrary key-value pairThe dictionary is empty and throws a Keyerror exceptionClear ()Empty dictionaryDictionary traversalFor ... in DictYou can trav
* Tool classes for operating collection and map: Collections--------------------------------------------------------------------------------------------------------------* Reverse (List): Reverses the order of the elements in the listShuffle (list): Randomly sort the elements of a List collectionSort (list): Sorts the specified List collection elements in ascending order based on the natural ordering of the elementsSort (list,comparator): Sorts the Li
) forKvinchret:Print(v,k)#The second wayDic={}with open ("Xx.log","R", encoding="Utf-8") as F: forLineinchF:line=line.split ("/") [2] ifLine not inchDic:data[line]=1Else: Data[line]+=1ret=sorted (Data.items (), key=LambdaX:x[1],reverse=True) forKvinchret:Print(v,k)This topic tests these knowledge points, re module, anonymous function, built-in function sorted,collections in the counterThese can be found in the basic article of the corresponding
Transformations between arrays, collections, strings in Java, and traversal with the enhanced for loop:1 @Test2 Public voidTestDemo5 () {3arraylistNewArraylist();4List.add ("A-B 1");5List.add ("A-B 2");6List.add ("A-B 3");7List.add ("A-B 4");8 // convert the collection to a string and separate it with ",": 9String join = Stringutils.join (list, ",");TenSystem.out.println ("join=" +join); One A // convert the set to an array:
First of all, I would first emphasize that I am a weak chicken farm, this essay is in my study Python3 in the tuple, dictionary, list, set these four kinds of common data types of some feelings, if there is something wrong to welcome everyone to correct. Thank you, everyone.Back to the point: This essay discusses lists, dictionaries, tuples, and collections. Therefore, it is necessary to make a brief analysis of three kinds of data types first:1: List
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.