Python Learning Note 4-data type-numbers

Source: Internet
Author: User

Number Type : Define variable is not quoted, and the quotation marks will be treated as a string

also includes int (shaping ) range from 2147483648 to 2147482647

Long , if you force a shape to be a long integer, you can add an L or L at the end when you define a variable.

float (float type) with decimal

complex (plural type) when defined at the back of the number with J, often used in parabolic

To see the type of data you can use the Tpye () function

string Type (str): the definition of the quotation marks, double quotation marks can be single quotation marks, generally no difference. The outermost quotation mark (or single quotation mark) should be used only if there is a single quotation mark (or double quotation mark) in the middle of the defined string.

if you want to wrap a line in a defined string, add \ n to the place where you want to wrap it

Sanchong Quotes: that is, to start three quotes, ending three quotes, in Sanchong quotation marks can be more intuitive do not need to use line breaks, where you want to wrap the line can be, because the triple quotes are automatically added \ n after wrapping, so you can more intuitively define the line break.

Slices in a string:

Each character in a string has an index, the first one is 0, the second is 1, .... And so on, when a negative number is from the back forward

Operation mode:

str[0,1,...] The character that can be taken out of the corresponding index number

Str[1:] To remove the character from index 1 to the last character

Str[:6] To remove the character from index 0 to the fifth character

STR[::1] Defines a step value of 1, if the No step value defaults to 1, when a negative number indicates a right-to-left

str[::] or str[:] Remove all characters

Python Learning Note 4-data type-numbers

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.