如何做多行注释?大多数语言都有块注释符号,比如:

/*

*/

当前回答

好吧,你可以试试这个(当运行引号时,第一个问题的输入应该用'引号括起来):

"""
print("What's your name? ")
myName = input()
print("It's nice to meet you " + myName)
print("Number of characters is ")
print(len(myName))
age = input("What's your age? ")
print("You will be " + str(int(age)+1) + " next year.")

"""
a = input()
print(a)
print(a*5)

"""之间的任何内容都将被注释。

如果你正在寻找单行注释,那么它是#。

其他回答

如果在带有代码的一行中编写注释,则必须在#符号之前留下2个空格,在#符号之前留下1个空格

print("Hello World")  # printing

如果在新行上写注释,必须写注释,在#符号中留下1个空格kn

# single line comment

要编写超过一行的注释,需要使用3个引号

"""
This is a comment
written in
more than just one line
"""

Python 2.7.13:

单:

"A sample single line comment "

多行:

"""
A sample
multiline comment
on PyCharm
"""

在windows中:你也可以选择文本或代码块,按CTR + /,如果你想删除注释,也可以这样做。 在mac中:它应该是comment + /

Python中的多行注释:

对我来说,“’”和“”都管用。

例子:

a = 10
b = 20
c = a+b
'''
print ('hello')
'''
print ('Addition is: ', a+b)

例子:

a = 10
b = 20
c = a+b
"""
print('hello')
"""
print('Addition is: ', a+b)

好吧,你可以试试这个(当运行引号时,第一个问题的输入应该用'引号括起来):

"""
print("What's your name? ")
myName = input()
print("It's nice to meet you " + myName)
print("Number of characters is ")
print(len(myName))
age = input("What's your age? ")
print("You will be " + str(int(age)+1) + " next year.")

"""
a = input()
print(a)
print(a*5)

"""之间的任何内容都将被注释。

如果你正在寻找单行注释,那么它是#。