It refers to the f-strings f
or F
the beginning of the string, which {}
expression contains a value will be replaced. (Currently supports python3.6 version)
F-strings look below to use
The basic use (action: replacement value)
>>>name = 'hoxis' >>> age = 18 >>> f"hi, {name}, are you {age}" #结果如下 'hi, hoxis, are you 18' >>> F"hi, {name}, are you {age}" 'hi, hoxis, are you 18'
Before adding string string escaping prevented r
Role: There is no escape special characters or can not print.
>>> s='abc\nabc' >>> s 'abc\nabc' >>> print s abc abc >>> s=r'abc\nabc' >>> s 'abc\\nabc' >>> print s abc\nabc
u / U: represents the unicode string
is not only for the Chinese, may, on behalf of the string is encoded for any unicode strings.
Generally use English characters in a variety of coding, the basic can be properly resolved, it is generally not with u; however Chinese, must show the required encoding, transcoding Otherwise, if there will be garbled. Recommended for all coding using utf8
Before adding the string "l"
Represents a wide character, unicode characters (two-byte unicode character set is composed .L notices compiler uses two-byte unicode character set) as L "My string" represents a character string converted into ANSI character unicode series is that each character occupies two bytes.
When no bytes occupied strlen ( "asd") = 3 ; add bytes occupied after strlen (L "asd") = 6;