Python Common functions C

Source: Internet
Author: User

Counter(hashable)

The number of elements per element can be hashed directly using statistics.

Most_common: The maximum number of n elements can be counted.

Statistical results support the combination of mathematical operations.

CompresS (iterable, callable)

Select the element to which the output corresponds to True based on the sequence .

Example:

Compile (Regular Expression)

precompiling A pattern string as a pattern object , the string is matched by that pattern.

Example:

Capitalize(String)

Returns a copy of a string with only the first letter capitalized.

Example:

Center (string)

format string, centered, supports incoming padding values.

Example:

Choice (Iterable)

the random choice method can be randomly selected.

Example:

Combinations(iterable, int)

Itertools of the Combinations method can produce all combinations of a collection and accept a parameter to specify the length.

Example:

combinations_with_replacement(iterable, int)

with the Combinations similar, but allows repeating selection of data.

Example:

chain(iterable,iterable)

Itertools The chain function can to accept one or more iterations of an object made as the input parameter. You then create an iterator that sequentially returns the elements in each of the iterated objects.

Example:

callable (object)

callable is checks whether object objects can be called. If true, object may still call failed, but if return False, the call Ojbect will never succeed.

Example:

CMP (object, Object)

compares two objects x and y, if x < y, returns a negative number;x = = y, returns 0 ; x > Y, returns a positive number .

Example:

Python Common functions C

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.