Python - PEP8 悬挂缩进错误信息
Python - PEP8 hanging indent error message
对于以下代码,我收到以下错误:
config = {
'bucket': json.loads(record['body'])
['Records'][0]['s3']['bucket']['name'],
'key': json.loads(record['body'])
['Records'][0]['s3']['object']['key']
}
E131 continuation line unaligned for hanging indent
['Records'][0]['s3']['bucket']['name'],
E131 continuation line unaligned for hanging indent
['Records'][0]['s3']['object']['key']
我已经尝试了一些选项,包括以下 - 但它不起作用:
config = {
'bucket': json.loads(
record['body']
)
['Records'][0]['s3']['bucket']['name'],
'key': json.loads(record['body'])
['Records'][0]['s3']['object']['key']
}
我也试过在行尾 + \
但也不起作用
试试这个,应该是这个格式
config = {
'bucket': json.loads(record['body'])['Records'][0]['s3']['bucket']['name'],
'key': json.loads(record['body'])['Records'][0]['s3']['object']['key']
}
或在此,
config = {
'bucket': json.loads(record['body']) \
['Records'][0]['s3']['bucket']['name'],
'key': json.loads(record['body']) \
['Records'][0]['s3']['object']['key']
}
更多信息,请查看What is PEP8's E128: continuation line under-indented for visual indent?问题。
为了符合 PEP8,以下适用于此场景:
config = {
'bucket': json.loads(record['body'])
['Records'][0]['s3']['bucket']['name'],
'key': json.loads(record['body'])
['Records'][0]['s3']['object']['key']
}
对于以下代码,我收到以下错误:
config = {
'bucket': json.loads(record['body'])
['Records'][0]['s3']['bucket']['name'],
'key': json.loads(record['body'])
['Records'][0]['s3']['object']['key']
}
E131 continuation line unaligned for hanging indent
['Records'][0]['s3']['bucket']['name'],
E131 continuation line unaligned for hanging indent
['Records'][0]['s3']['object']['key']
我已经尝试了一些选项,包括以下 - 但它不起作用:
config = {
'bucket': json.loads(
record['body']
)
['Records'][0]['s3']['bucket']['name'],
'key': json.loads(record['body'])
['Records'][0]['s3']['object']['key']
}
我也试过在行尾 + \
但也不起作用
试试这个,应该是这个格式
config = {
'bucket': json.loads(record['body'])['Records'][0]['s3']['bucket']['name'],
'key': json.loads(record['body'])['Records'][0]['s3']['object']['key']
}
或在此,
config = {
'bucket': json.loads(record['body']) \
['Records'][0]['s3']['bucket']['name'],
'key': json.loads(record['body']) \
['Records'][0]['s3']['object']['key']
}
更多信息,请查看What is PEP8's E128: continuation line under-indented for visual indent?问题。
为了符合 PEP8,以下适用于此场景:
config = {
'bucket': json.loads(record['body'])
['Records'][0]['s3']['bucket']['name'],
'key': json.loads(record['body'])
['Records'][0]['s3']['object']['key']
}