Not just for Chinese , For any string , Represents a string that is unicode code .
General English characters in the use of a variety of encoding , Basically, it can be parsed normally , So I don't usually bring it u; But Chinese , The required code must be indicated , Otherwise, once the code is converted, there will be garbled code .
It is recommended that all coding methods adopt utf8 code .
Ordinary characters are added \ May be used by the compiler as escape characters , For example, the most common ”\n” Means line break ,”\t” Express Tab etc. , Such a string may not express what we want . And if so r start , Then explain the following characters , They are all ordinary characters , That is, if it is “\n”, Add... To the front r after , It becomes a string r"\n" that " " The string in represents the original meaning , namely A backslash character , A letter n, Not a line break .
With r Start character , Often used in regular expressions , Corresponding re modular .
python3.x Default in str yes (py2.x Inside )unicode, bytes yes (py2.x) Of str, "b" The prefix stands for bytes
python2.x in , b Prefixes don't make any sense , Just for compatibility python3.x This way of writing
Summary of string operation methods in Python - Summary (about 40 operation methods), with sample code
use Python Do algorithms , Not
Example of method of adjusting legend position by Matplotlib in Python
Catalog Preface 1.loc=‘String