在尝试开发一个类时,我遇到了这个错误。在
from __future__ import division
import numpy as np
import scipy as sp
import itertools as it
from scipy.integrate import quad
import astropy.cosmology
from astropy import units as u
class NFW:
File "/Users/alexandres/Illustris/Scripts/NFWprofile2.py", line 10
^
IndentationError: expected an indented block
[Finished in 0.1s with exit code 1]
[shell_cmd: python -u "/Users/alexandres/Illustris/Scripts/NFWprofile2.py"]
[dir: /Users/alexandres/Illustris/Scripts]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
这怎么会是缩进错误?在
不管我是将类定义为NFW()
还是NFW(object)
,都会发生这种情况。在
这是正在编辑的崇高3
如果这是您的整个文件,则缺少所需的类主体。您可以使用
pass
语句创建空正文:发生错误是因为您有一个块中没有语句。在
也就是说,
class NFW
是空的。在为了创建一个最小的类
对你来说
^{pr2}$pass语句什么也不做。当语法上需要语句但程序不需要操作时,可以使用它。在
相关问题 更多 >
编程相关推荐