0
How to create a string using double quotes
2 Answers
+ 4
Many ways:
- enclosed by double quotes, you can 'escape' double quotes by prepend an 'anti-slash' character ( \ ) to inform Python that next character is not the closing quote boundary of the string
- enclosed by simple quote, you doesn't have to explicit that the doubles quotes are inside the string, because Python wait for a simple quote closing boundary
- enclosed by triple double quote, the expected closing boundary is expected to be 3 doubles quotes, so you don't need to 'escape' then, except if it's placed at end (Python will consider the 3 first double quotes), or obviously if you want to set triple double quote inside the string
- enclosed by triple simple quote, same as unique simple quotes: it's enough explicit
Obviously, in same kind of way, you have to be aware of simple quote inside simple quoted string boundaries ^^
0
print("this is a text \"with double quotes\"")