Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3,4 getattr无效语法_Python - Fatal编程技术网

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