In the previous article, we learned
python string, and know how to use some strings, learn how to do
python string interceptionand update the modified string. These are some of the more simple ways to handle strings, and then we continue to learn about them.
python escape character: Python uses a backslash (\) to escape characters when special characters are required in characters. See the table below for details:
Now let's look at the python string operator :
First we first define the instance variable a value as the string "Hello" and the B variable value to "Python":
The operator is not very much, and can be understood and skilled according to the table above.
Let me give you some examples to illustrate:
#!/usr/bin/python#-*-coding:utf-8-*-a = "Hello" b = "python" print "A + B output result:", A + b print "A * 2 output:", A * 2 pri NT "a[1] Output:", a[1] print "a[1:4" output: ", A[1:4] if (" H "in a): print" H is in variable a "else: print" H is not in variable a " if ("M" Not in a): print "M is not in variable a" else: print "m in variable a" print r \ n ' Print R ' \ n '
The result of the example above is as follows:
A + B output result: Hellopythona * 2 output: hellohelloa[1] Output result: ea[1:4] Output: ELLH in variable A is not in variable a \ n
In this article, we learned about the Python escape character and the Python string operator, which not only lists two table-assisted learning but also demonstrates some of its examples to help understand. Python strings are a very useful point of knowledge and you will find yourself able to use them in many situations. Finally, I hope that this article will give you a little help in learning about Python.
For more information, please visit the PHP Chinese Web Python tutorial section.