0

In Python v.3.x, what better to use for string ' or '' (quotes or double quotes )?

12th Jul 2017, 2:43 PM
Gideon
Gideon - avatar
3 Antworten
+ 4
It doesn't matter: the only difference is what quotes needs to be escaped ^^ Else, you can use triple quotes (simple or double), which provide also possibility to write multilines string (not mandatory to escape new line characters ;))
12th Jul 2017, 4:31 PM
visph
visph - avatar
+ 1
it's only up to you, i use double quotes just because i'm used to, but for instance, if i need to use double quotes inside a string, it's confortable using single quotes to delimitate it. exemple: string=' Mark says:"Hello, how are you?" ' #Here i use single quotes to delimiate the string because i use double quotes inside the string...
12th Jul 2017, 3:01 PM
2_3rr0r5
2_3rr0r5 - avatar
0
Thank you for reply! By the way for eliminating quotes, you could use "\" example: string=' Mark says:\"Hello, how are you?\" '
12th Jul 2017, 3:21 PM
Gideon
Gideon - avatar