There are three ways to comment multiple lines in Python: use ctrl / to comment multiple lines, use the shift # key at the beginning of each line, enter ''' ''' or """ " "", insert the code to be commented in the middle
We often comment the code in the process of writing code. However, commenting line by line is troublesome. In the following two articles, we will introduce how to comment multiple lines of code in the Python language. It has a certain reference value and I hope it will be helpful to everyone
[Recommended course: Python tutorial]
Multi-line code comment
Method 1: First select the paragraph to be commented, and then press ctrl / to comment multi-line code. The effect is as follows:
Press ctrl / again to uncomment the
method Two: Just like commenting a single line, enter shift
##r+=(i-arr[idx])*rat[idx] #print (i-arr[idx])*rat[idx] #i=arr[idx]
in front of each line. Method three: You can enter ''' ''' or """ """ to insert the code to be commented. In the middle, you can also achieve the effect of commenting on multiple lines of code
Summary: The above is the entire content of this article. I hope it will be helpful to everyone learning the Python language. .
The above is the detailed content of How to comment multiple lines in python. For more information, please follow other related articles on the PHP Chinese website!