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

前端 未结 3 1616
梦毁少年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:51

    Choose whatever style you want. Personally I use single quotes everywhere I can in Python.

    The documentation states:

    "String literals can be enclosed in matching single quotes (') or double quotes (")."
    

    It doesn't matter which one you decide to use. What does matter, is that you stick with your decision. It is good practice to choose a style and stick with it.

提交回复
热议问题