From: http://our2848884.blog.163.com/blog/static/146854834201192393137281/
Anyone who has learned Python should know that python contains single quotation marks, double quotation marks, and three quotation marks. But what are their differences?
Actually, I personally think that python is different from PHP, and there is no difference between single quotes and double quotes. Their main function is to avoid escape characters. For example:
>>> A = 'I \'m a student. '>>> print AI' m a student. >>> A = "I'm a student. ">>> print AI'm a student. >>> B = "\" knuth \ "is a genius. ">>> print B" knuth "is a genius. >>> B = '"knuth" is a genius'> Print B "knuth" is a genius
As for the three quotation marks, the main purpose is to input multiple lines of text. That is to say, the content entered between the three quotation marks will be reserved as is, and the single and double quotation marks in the quotation marks do not need to be escaped, invisible characters, such as \ n and \ t, are retained. The advantage is that you can replace multiple lines of text.
C = ''' the Zen of Python, by Tim Peters beautiful is better than uugly. explicit is better than implicit. simple is better than complex. complex is better than complicated. flat is better than nested. sparse is better than dense. readability counts. special cases aren't special enough to break the rules. although practicality beats purity. errors shoshould never pass silently. unless explicitly silenced. in Face of ambiguity, refuse the temptation to guess. there shoshould be one -- and preferably only one -- obvious way to do it. although that way may not be obvious at first unless you're Dutch. now is better than never. although never is often better than * right * now. if the implementation is hard to explain, it's a bad idea. if the implementation is easy to explain, it may be a good idea. namespaces are one H Onking great idea -- let's do more of those! '''Print C will not stick to the print result. Let's go back and try it.