Python data type

Source: Internet
Author: User
Tags set set

Data types for Python:

    1. Number (int, float, bool, complex)
    2. String
    3. List
    4. Tuple
    5. Set
    6. Dictionary

To view the data types type ():

In Python3, the integer type is only int, there is no long integer type, and we can see the data type of the variable or constant through type ().

We can clear the contents of the variables we declare by using the DEL keyword.

String strings:

strings are indexed (subscript) to locate each character in a string, the sequential index starts at 0, the reverse index starts at 1, the string is copied using *, and the string is spliced with +, but the data type must be the STR string type in the stitching process.

Escaping occurs when the "\" or "//" escape character is present in a string, where we can precede the string with an "R" to make the string output the original content (emphasizing that it cannot be changed after the string declaration in Python)

List of lists:

The list is written in brackets and the elements are separated by commas, such as List = [' Hello ', ' world ']

List lists can be stitched by + or copied via *

The elements of list lists are mutable

List lists can work with indexes, slices, and so on

function operations on list lists and string strings are explained in subsequent articles

Tuple Ganso:

The difference between the Ganso and the list is first in the format: list = [' Hello ', ' world '], tuple = (' element1 ', ' element2 '), and in addition to the list, the tuple element is immutable

Other property functions are consistent with string, but in a sense the string is a special Ganso, a subset of the Ganso

Set Set:

Set can use {} and set () to create a collection, but if you want to create an empty collection you must use Set (), because {} is the way to create an empty dictionary

Set can automatically remove duplicate elements and enter non-sequential outputs

Set can perform set operations

Dictionary dictionary:

A dictionary is a type of mapping, in the form of dictionary = {' key ': ' Value '}, which is an unordered key (key): A value pair collection, in which the key (key) must be unique, and {} is used when creating an empty dictionary.

Knowledge is iterative every day, the article is updated every day, Python test Development Exchange Group: 875120095 welcome you to join!

Python 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.