Saltar al contenido

Python cómo comentar el ejemplo de código de varias líneas

Ejemplo 1: Python de comentarios multilínea

# While Python doesn't support multi-line comments, it can ignore anything
'''
inside a multi-line string!
Just wrap the comment in the three single quote marks,
And
you're
good
to
go!
'''

Ejemplo 2: Python comenta varias líneas

#There is no way to comment multiple lines in Python.
#You just keep using "#" symbol to comment each line out.

'''
Technically you could also use triple single quotation
marks like so, but this formatting does not count
as "true" source code comments that are removed by
a Python parser.
'''

Ejemplo 3: comentario de varias líneas de Python

#%% There are not multiline comments in python,
# this # is the only form of commenting but, people use
# """triple quotes""" for multiline commenting but this
# is actually a String the interpreter will read and 
# will ocupy memory. If you dont put this kind of string
# into a variable it will be collected on execution

Ejemplo 4: comentario de varias líneas de Python

def increase_salary(sal,rating,percentage):
    """ increase salary base on rating and percentage
    rating 1 - 2 no increase
    rating 3 - 4 increase 5%
    rating 4 - 6 increase 10%
 
    """

Ejemplo 5: comentar un bloque en Python

select the lines you want to comment
and 'use Ctrl + / to comment all of the selected text'.
To uncomment do the same thing.
OR
put a '#' before each line

eg : #This is a comment

Ejemplo 6: comentario de varias líneas en python

# This a comment
#Or This
#For a comment written in more than a line
#You just add triple quotes without assigning it a variable or putting it in a
#print statement
'''
Like This
But only for Python
As far as i know
'''
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)



Utiliza Nuestro Buscador

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *