我有一个字符串格式的代码块。它的变量名是我的\字符串,如下所示:
'<div class="section page-centered"><div><b style="font-size: 24px">About
Us</b></div><div>At <a href="https://close.com/" class="postings-
link">Close</a>, we\'re building the sales
communication platform of the future. With our roots as the very first
sales CRM to include built-in calling, we\'re leading the industry toward
eliminating manual processes and helping compa
nies to close more deals (faster). Since our founding in 2013, we\'ve
grown to become a profitable, 100% globally distributed team of ~33 high-
performing, happy people that are dedicated to b
uilding a product our customers love. </div>'
我想把所有东西都放在那块,除了反斜杠。我在这里看到了很多问题和答案
new_string = my_string.replace("\\", "")
但我得到的结果是一样的。我做错什么了?你知道吗
反斜杠实际上是在转义单引号。如果我打印字符串,我会得到:
<div class="section page-centered"><div><b style="font-size: 24px">About Us</b></div><div>At <a href="https://close.com/" class="postings- link">Close</a>, we're building the salescommunication platform of the future. With our roots as the very first sales CRM to include built-in calling, we're leading the industry toward eliminating manual processes and helping companies to close more deals (faster). Since our founding in 2013, we've grown to become a profitable, 100% globally distributed team of ~33 high- performing, happy people that are dedicated to building a product our customers love. </div>
我不太清楚为什么它在某些机器上工作,但至少在我的机器上,有这样一个问题:
作为
这将输出:
在IDE中更容易看到它的颜色。你知道吗
所以你可以看到,这是一个很特别的角色。和你在替补时做的一样,有两次反冲
正如在here中所说的,很难找到反冲。反斜杠(“\”)字符用于转义具有特殊含义的字符,例如换行符、反斜杠本身或引号字符。 可以使用前缀r或r:
字符串文本可以选择前缀字母“r”或“r”;这类字符串称为原始字符串,并使用不同的规则来解释反斜杠转义序列。你知道吗
看看this,他们提到:
正如您可能猜到的,\也需要转义,这样它就不会像转义字符那样工作。你必须。。。从本质上说,逃离。你知道吗
相关问题 更多 >
编程相关推荐