What's the difference on docstrings with triple SINGLE quotes and triple DOUBLE quotes?

前端 未结 3 1639
梦毁少年i
梦毁少年i 2021-01-01 16:08

I was just wondering what is the difference between two ways of writing Python Docstrings (__doc__):

  1. three single quotes:

    \'\'\         
    
    
            
3条回答
  •  我在风中等你
    2021-01-01 16:37

    No. They are the same. The only difference is that the first one can contain a sequence of three unescaped double quotes, while the second can contain a sequence of three unescaped single quotes. (In other words, because the delimiters are different, there is a slight difference in what characters you can use inside them.)

    Docstrings are just regular strings, and in Python there is no difference between the different string delimiters, except that, of course, you can't use the string delimiter inside the string.

提交回复
热议问题