user2002290
user2002290

Reputation: 687

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'>

Upvotes: 1

Views: 82

Answers (2)

Cameron Sparr
Cameron Sparr

Reputation: 3981

I would just use triple-quotes like below, there's other ways but triple-quotes are pretty fool-proof in Python:

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

Upvotes: 3

Simeon Visser
Simeon Visser

Reputation: 122326

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\'>'

Upvotes: 2

Related Questions