+ 2

How 3 sets of quotes escape the new line in an program?

examples

3rd Sep 2018, 3:14 PM
Hari Krishna Sahu
Hari Krishna Sahu - avatar
2 ответов
+ 1
Triple Quoted Comments? #This is a comment ''' ... ''' (single quotes / apostrophes) OR """ ... """ (double quotes / regular quotes) are sometimes referred to as "Multi-Line Comments" However, this is not true. Python only has one way to perform comments and that is the "#" symbol. Triple quotes are actually strings, but developers use the triple quote technique to add a clean multi-line comment. For example: ''' This is a comment. ''' #This is also a comment from timeit import timeit print(timeit(stmt= ''' print('This is a string with triple quotes.') ''', number=100)) Several functions in Python will require a triple quote string, much like the timeit library above. Again, it doesn't matter if you use double triple quotes (""" ... """) or single triple quotes (''' ... ''') the result will be the same. Best of luck.
3rd Sep 2018, 3:33 PM
Steven M
Steven M - avatar
+ 1
Or are you talking about ''' ''' in Python? :) Normally you would have to manually insert a newline into your string, like '1st line\n2nd line'. With triple quotes you can just press enter and write on in the next line and Python does it for you. (It ends up as the same thing, a string with a newline pasted in.)
3rd Sep 2018, 3:33 PM
HonFu
HonFu - avatar