Python Basic data type

Source: Internet
Author: User

Numeric type (number)

There are four types of numbers in Python: Integer, Boolean, floating-point, plural.

1 int 1 int , expressed as a long integer, with no python2 in it.  2bool  (Boolean), as True.  3float1.23, 3e-2411.12 .2j

Strings (String)

  • The single and double quotation marks in Python are used exactly the same.
  • Use the quotation marks ("' or" ") to specify a multiline string.
  • Escape character ' \ '
  • Backslashes can be used to escape, using R to allow backslashes to escape. such as R "This was a line with \ n \" will be displayed, not newline.
  • The literal cascading string, such as "This" and "is" and "string", is automatically converted to this is string.
  • Strings can be concatenated with the + operator and repeated with the * operator.
  • There are two ways to index a string in Python, starting from left to right and starting at 0 from right to left with-1.
  • The string in Python cannot be changed.
  • Python does not have a separate character type, and one character is a string of length 1.
  • The syntax for intercepting a string is as follows: variable [head subscript: tail subscript]
    1 ' string ' 2 " This is a sentence.  "3" "" This is a paragraph,4 can consist of multiple lines " " "

Python Basic data type

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.