[当我想为代码编写解释性注释时,但行很长,分割注释的最佳方法是什么?
最好通过在其后进行如下新评论来继续评论
schedule.pop(0) # reads the file of programs as a list and pops the two first lines
list_of_program = [] # creates an empty list where the programs and their attributes current_channel = ""
# stores the channels from the for-loop
for program_line in schedule: # builds the list from a for-loop by splitting the lines in the list
if program_line[0] == "-": # to get each attribute necessary to identify the program
continue
或者我应该以其他方式分开?
在Python文档中,您可以使用“”“进行多行注释。但是,这种用法通常是出于文档目的而创建的。
示例用法:
"""
This is multi line
commenting
"""
而且pep-8格式对于性能也很重要。