+ 1
What's the difference between comments and docstring in python?
for example while running a code . the problem is I find both similar ..how can I use them in programs?
3 Respuestas
+ 1
A docstring is like a multi-line comment.
A normal comment is a single line comment.
+ 1
Docstring can contain more than one comments but comments is just a single line. e.g
Docstring=
'''ksjsddkdkkdjd
snnsjdjdjd
snjkdkdkdhdjdkkddj'''
comment=
#jkssjbddkdk
0
There's not much difference when you're normally running the code. But docstrings can be accessed from outside the file using the help() function. Docstrings are normally written at the beginning of each module/class explaining what it does. Read more here: https://en.m.wikipedia.org/wiki/Docstring#JUMP_LINK__&&__Python__&&__JUMP_LINK