How To Comment Multiple Lines In Python

This article will tell you three methods about how to add comments to multiple lines in python source code.

1. Three methods to add comments in python source code.

  1. First, select the paragraph to be commented in python source code, and then press "Ctrl + /" on Windows, "Command + /" on macOS to comment the selected multiple lines of code. The effect is as follows. If you want to cancel the comments, you can press "Ctrl + /" on Windows, "Command + /" on macOS again to uncomment the comments.
    #     # Create an instance of etree.HTMLParser class.
    #     html_parser = etree.HTMLParser()
    #       
    #     # Use the python requests module get method to get the web page object with the provided url.
    #     web_page = requests.get(page_url)
  2. Press "Shift + #" in front of each python source code line to comment on each line then it will comment on all the lines.
  3. You can insert the commented python source code in  '''  python source code    ''' or """  python source code  """  to implement multiple python source code lines comments.

2 thoughts on “How To Comment Multiple Lines In Python”

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.