擅长:python、mysql、java
<ol>
<li><strong>u-strings</strong>如果是python2中的unicode。如果您正在使用现代应用程序,那么您可能应该忘记这一点—Python3中的默认字符串都是unicode,如果您从Python2迁移,您很可能会使用<code>from __future__ import unicode_literals</code>,这使得Python2几乎相同</li>
<li><p><strong>b-strings</strong>用于原始字节-不知道<em>文本</em>,而只是字节流。很少用作源代码的输入,通常是由于网络或低级代码读取二进制格式的数据、解包归档文件、使用加密库。在</p>
<p>通过<code>.encode</code>&;<code>.decode</code></p></li>
<li><p><strong>r-strings</strong>不是专门针对regex的,这是“原始”字符串。与常规字符串文本不同,r-string对转义字符没有任何特殊的含义。一、 普通字符串<code>abc\n</code>长4个字符,最后一个字符是“newline”特殊字符。为了以文字形式提供它,我们使用了带<code>\</code>的转义。对于原始字符串,<code>r'abc\n'</code>是5个长度的字符串,最后两个字符是<code>\</code>和{<cd9>}。经常可以在两个地方看到原始字符串:</p>
<ul>
<li><p>正则表达式模式-不要在模式中使用实际的特殊字符进行转义</p></li>
<li><p>windows系统的文件路径表示法,因为windows家族使用<code>\</code>作为限定符,普通的字符串文字看起来像<code>'C:\\dir\\file'</code>,或者{<cd12>},而raw则更好:<code>r'C:\dir\file'</code>和{<cd14>}</p></li>
</ul></li>
<li><p>另一个值得注意的是<strong>f-strings</strong>,它在python 3.6中作为一种简单而强大的格式化字符串的方式而出现:</p>
<ul>
<li><code>f'a equals {a} and b is {b}'</code>将在运行时替换变量<code>a</code>和{<cd17>}。在</li>
</ul></li>
</ol>