如何修复Python中的IndetationError?
from timeit import Timer
timer_obj1 = Timer('list_sum()'),
'from_main_import list_sum'
timer_obj2 = Timer('numpy_arr_sum()'),
'from_main_import numpy_arr_sum'
print('Pure python version:',timer_obj1.timeit(1000))
print('Numpy version:',timer_obj2.timeit(1000))
这是我输入的代码 运行后,第 3 行显示意外缩进 有人可以帮我吗?
from timeit import Timer
timer_obj1 = Timer('list_sum()'),
'from_main_import list_sum'
timer_obj2 = Timer('numpy_arr_sum()'),
'from_main_import numpy_arr_sum'
print('Pure python version:',timer_obj1.timeit(1000))
print('Numpy version:',timer_obj2.timeit(1000))
this is the code I key in
after run it, shows unexpected indent in line 3
Anyone can help me out, please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

您关闭了 Timer 类的构造函数(基本上是一个函数)的括号,但尝试使用不同的缩进向其插入另一个参数。你不能那样做。
这样做:
You closed the parentheses of Timer class's constructor (basically a function), but attempted to insert another argument to it with a different indent. You can't do that.
Do it like that: