简体   繁体   中英

Python Special Chars Escape

how would I get this into a string in python? I know I need to escape special chars but I don't know how. I tried adding backslashes but it didn't seem to work. I' not sure what to do.

Here is the code:

</th><td class='tracking'>

我将像下面那样使用三引号,还有其他方法,但是三引号在Python中非常简单:

"""</th><td class='tracking'>"""

You can use double quotations:

s = "</th><td class='tracking'>"

This allows you to create a string which includes single quotations.

Single quotations work as well when you use backslashes for escaping:

s = '</th><td class=\'tracking\'>'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM