如何在 Python 字典中添加注释?
pythonprogramming
您可以像平常一样在 Python 脚本的任何地方添加注释。但请注意,您只能使用 # 添加单行注释。多行注释的作用类似于字符串,您不能在字典定义之间只添加一个字符串。例如,以下声明完全有效:
testItems = { 'TestOne': 'Hello', # 'TestTwo': None, }
但以下内容不是:
testItems = { 'TestOne': 'Hello', """ Some random multiline comment """ }