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