Python values and strings

Source: Internet
Author: User

Python data type

Numerical

String

List

Meta-group

Dictionary


1.1 Types of numeric values

Plastic

Long integer type

Floating point number

Plural class


String type, there are 3 ways to define:

There is no difference between single and double quotes in Python, where single quotes are fully referenced in the shell, and double quotes represent partial references.

str = ' This is a string '

str = "This is a string"

str = "This is a string"


A = "Hello\nworld"

Sanchong quotes can either represent comments or define strings.

Strings belong to " sequences"and can be indexed and sliced operations.

A = ' ABCDE '

A[-1] indicates the last character

A[0]+A[1] value is AB

A[0:2] means taking from the first start, taking to the 2nd one.

Usually 0 is omitted, the expression is taken from the first start

The second ellipsis indicates the string to be taken to the last one.


A[-1:]

Step A[::1]


To take from the back:

A[-4:-2] can be taken to BC


Abcd

[ -4,-2]


This article is from the "less stubborn" blog, please be sure to keep this source http://xushaojie.blog.51cto.com/6205370/1795127

Python values and strings

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.