Python's transfer character (study Note III)
Escape character \ Can escape many characters, such as \ n for newline, \ t for tab, character \ itself to escape, so \ \ means the character is \, you can print a string in Python's interactive command line to see:
Command:
>>>print ' he\ ' s a boy. '
>>>print ' I\ ' m learning\nlinux. '
>>>print ' \\\n\\ '
:
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/92/A4/wKioL1kBlGWQJlqSAAAREQcbjqs123.png "title=" 22. PNG "alt=" Wkiol1kblgwqjlqsaaareqcbjqs123.png "/>
If there are many characters in the string that need to be escaped, you need to add a lot of \, in order to simplify, Python also allows to use R ' ' to indicate that the string inside of ' is not escaped by default, for example:
Command:
print ' \\\ ' n\\
Print R ' \\\ ' n\\ #r与引号之间是没有空格的!
:
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/92/A5/wKiom1kBl1LRAGS3AAAGstS04Sg674.png "title=" 22. PNG "alt=" Wkiom1kbl1lrags3aaagsts04sg674.png "/>
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/92/A6/wKiom1kBmtSDoYaWAAAQHa5lU7Q497.png "title=" 22. PNG "alt=" Wkiom1kbmtsdoyawaaaqha5lu7q497.png "/>
If there is a lot of line wrapping inside the string, it is not good to read it in a line, in order to simplify, Python allows "..." format to represent multiple lines of content, for example:
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/92/A5/wKioL1kBmdezy6gEAAAOY_4uoQ4192.png "title=" 22. PNG "alt=" Wkiol1kbmdezy6geaaaoy_4uoq4192.png "/>
Note:
Multi-line string ' ... ' You can also add R to the front, so the example above can be written as well.
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/92/A5/wKioL1kBm36g3uLSAAASAk631zE642.png "title=" 22. PNG "alt=" Wkiol1kbm36g3ulsaaasak631ze642.png "/>
This article is from the "Hand of the Paladin Control" blog, please make sure to keep this source http://wutengfei.blog.51cto.com/10942117/1920054
Python's transfer character (study Note III)