这行不通:
something = \
line_of_code * \ # Comment
another_line_of_code * \ # Comment
and_another_one * \ # Comment
etc
这也一样不行:
something = \
# Comment \
line_of_code * \
# Comment \
another_line_of_code * ...
这也不行:
something = \
''' Comment ''' \
line_of_code * \
''' Comment ''' \
another_line_of_code * ...
在代码中,有没有一种方法可以将注释分成多行?
obj.method1(args1).method2(args2).method3(args3)
- iago-litoa=obj.method1(args) # comm1
和b=obj.method2(args2) # comm2
等。 - Demisobj.method1(
\n# Important method 1
\nargs1
\n).method2(
\n# Importand other method
\nargs2
\n).method3(
\n# Method that needs to be called last
\nargs3
\n)
。可能看起来有些繁琐,但嘿 - 是您想要在链中注释每个方法 :) - Tadeck