Python 3,4 getattr无效语法
我有一个包含不同查询的数组Python 3,4 getattr无效语法,python,Python,我有一个包含不同查询的数组 month = ['jan', 'feb', 'mar'] monthly_bill = [ getattr(my.path.to, x) for x in month \ if x is not None] 但是,我得到了一个无效的语法错误 *** SyntaxError: Invalid syntax 如何使用getattr正确访问每个查询?尝试关闭]并删除\ month = ['jan', 'feb', 'mar'] monthly_bill = [ g
month = ['jan', 'feb', 'mar']
monthly_bill = [ getattr(my.path.to, x) for x in month \ if x is not None]
但是,我得到了一个无效的语法错误
*** SyntaxError: Invalid syntax
如何使用getattr正确访问每个查询?尝试关闭
]
并删除\
month = ['jan', 'feb', 'mar']
monthly_bill = [ getattr(my.path.to, x) for x in month if x is not None]
谢谢,在我的代码中,它在多行上。没有一种人还在进来,有什么想法吗?thanksHow如果您在上面的一行中定义了一个明确无
None
的列表,它们会是None
?