我收到此错误,但无论我选择缩进它,我仍然收到它,您知道为什么吗?
if len(argmaxcomp) == 1:
print "The complex with the greatest mean abundance is: {0}"\
.format(argmaxcomp[0])
最佳答案
通常 pep8 建议你 prefer parenthesis over continuation lines .
The preferred way of wrapping long lines is by using Python's implied line continuation inside parentheses, brackets and braces. Long lines can be broken over multiple lines by wrapping expressions in parentheses. These should be used in preference to using a backslash for line continuation.
即:
if len(argmaxcomp) == 1:
print("The complex with the greatest mean abundance is: {0}"
.format(argmaxcomp[0]))
另一种选择是使用 python 3 的打印:
from __future__ import print_function
if len(argmaxcomp) == 1:
print("The complex with the greatest mean abundance is:", argmaxcomp[0])
注意:print_function 可能会中断/需要更新其余代码...在您使用过 print 的任何地方。
关于Python、PEP-8、E122 续行缺少缩进或缩进,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33147599/