我从未在生活中使用过SageMath,我依靠互联网进行速成课程,了解如何从SageMath中获取我想要的东西(在有限域上绘制椭圆曲线)。
我使用this code,粘贴在下面:
@interact
def f(label='37a', p=tuple(prime_range(1000))):
try: E = EllipticCurve(label)
except:
print "invalid label %s"%label; return
try:
show(graphics_array([plot(E,thickness=3),plot(E.change_ring(GF(p)))]),frame=True)
except Exception, msg:
print msg
似乎缺少一个支架,但我没有经验知道它应该去哪里。我得到的错误信息是:
Error in lines 1-6
Traceback (most recent call last):
File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 905, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "<string>", line 4
except:
^
IndentationError: unindent does not match any outer indentation level
答案 0 :(得分:1)
您提供的错误似乎表明except:
之后的行不缩进超过except:
。 Python非常关注缩进级别。
您可以尝试以下操作。
@interact
def f(label='37a', p=tuple(prime_range(1000))):
try:
E = EllipticCurve(label)
except:
print "invalid label %s"%label; return
try:
show(graphics_array([plot(E,thickness=3), plot(E.change_ring(GF(p)))]), frame=True)
except Exception, msg:
print msg
除此之外:您应该在代码之前使用四个空格将它们显示为代码块。有关更多信息,请参阅How do I format My Code Blocks?