1, string before plus u
Example: U "I am a string that contains Chinese characters. "
Function: The following string is encoded in Unicode format, generally used in front of the Chinese string, to prevent the source code storage format problems, resulting in re-use garbled.
PS: Not just for Chinese, you can target any string, and the representation is on the string. General English characters in the use of various codes, the basic can be parsed normally, so generally without u. But there are problems in Chinese, it is necessary to think before the school on the machine to tap the code when the same, a plug, a copy of the source code, a open, the Chinese part of the whole box garbled ... The thief was embarrassed ...
2. Add r before string
Example: R "\n\n\n\n\n\n"
Function: The string following the declaration is a normal string, relative, special string contains: The escape character \ t what.
Test results:
Usage: Generally used in regular expressions, file absolute address, etc...
3, string before plus B
Function: The default str in python3.x is (py2.x) Unicode, Bytes is (py2.x) str, b "" prefix represents bytes
python2.x, the B prefix is nothing specific, just to be compatible with python3.x.
4, after the statement:
Reference: http://blog.csdn.net/u010496169/article/details/70045895
Reprint please indicate the source ('? ') ): http://www.cnblogs.com/Twobox/
2017-08-22 23:45:36
[Python] [Small knowledge] Python string with u, r, b meaning