Reading this study note requires a certain language base. If you have nothing to say, let's start.I. Assignment and numbers
Python assignment is simple:
Number = 1 # Number = 2 + 2 # support for addition, subtraction, multiplication, division, number = (1 + 2j) * (1-1j) # support for complex operationsIi. String
STR = "Hello, world! "# String
You can also use three consecutive single quotes or double quotation marks to represent a string, similar to the PRE Tag in HTML, which can be directly output in actual format.
Print "" * "'% """
Strings can be connected by the + operation (or put together), or the * operation can be used for repetition.
WORD = 'test' + 'er' word2 = word * 2
AndC LanguageHowever, Python strings cannot be modified. For example, if word = 'hello', you want to change it to word = 'aello ', you cannot execute a statement like word  = 'A. But you can do this:
Word2 = 'A' + word [1:]
We can easily intercept a segment in a string. For example, we can intercept three characters starting with subscript 2 and ending with subscript 4, that is, word [2: 5].
Since python2.0, Unicode strings are supported. It is very easy to create a unicode string:
WORD = u'hello world! "
The "U" before the quotation marks indicates that the string is a unicode string. It can also be encoded with Unicode characters:
WORD = u'hello \ u0020world! ", U0020 is a space character.