Python: Data types and variables

Source: Internet
Author: User

Key points of study today (source: Liao Xuefeng official website)
Python data types include:

  1. Integer
  2. Floating point number
  3. String
  4. Boolean value
  5. Null value

Take a look at the difference between each data type:

  • Integer: Contains a positive integer, a negative integer, and 0. For example: -120,0,200, etc.;
  • Floating point: That is, the number with a decimal point. For example, 1.0,1.65, etc.;
  • String: The string is any text enclosed in single quotation marks "or double quotation marks", such as: ' Xiao Ming is 3 years old this year, or a baby ', "XYZ" and so on;

    • If the string contains both ' and contains ', you can use the escape character \ to identify it (see ' or ' before it is inserted. For example: ' I ' m "OK"! ' means the string content is I ' m "OK"!;
    • Escape characters can escape many characters, such as \ n for line breaks, and \ t for tabs. The character \ itself also needs to be escaped, so \ escape result is;
    • If you have a lot of line breaks, you can use three quotation marks, and then add a carriage return to complete the line-break input. For example:
    • Not escaped: strings that use R ' ' to denote ' are not escaped by default. For example: R ' \\t\ ', the string content of the expression is: \\t\;
  • Boolean value
  • Null value

Python: Data types and variables

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.