Type conversions like Python

Source: Internet
Author: User

function Description

int (x [, Base])

Convert x to an integer

Long (x [, Base])

Convert x to a long integer

Float (x)

Convert x to a floating-point number

Complex (real [, Imag])

Create a complex number

STR (x)

Convert an object x to a string

REPR (x)

Convert an object x to an expression string

eval (str)

Used to evaluate a valid Python expression in a string and return an object

Tuple (s)

Converting a sequence s to a tuple

List (s)

Convert the sequence s to a list

Set (s)

Convert to mutable Collection

Dict (d)

Create a dictionary. D must be a sequence (key,value) tuple.

Frozenset (s)

Convert to immutable Collection

Chr (x)

Converts an integer to one character

UNICHR (x)

Converts an integer to a Unicode character

Ord (x)

Converts a character to its integer value

Hex (x)

Converts an integer to a hexadecimal string

Oct (x)

Converts an integer to an octal string

View variable data type: A=3import typestype (a) int (a) #转换为整型str (a) #转换为字符串

Type conversions like Python

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.