在下面的代码中的print statements和plot.hist命令中,python返回一条语句,说明这些行包含语法错误。我很确定我有正确的文档,所以也许在语句前面的for循环中的缩进是不正确的?谢谢!
import pyfits
import math
import numpy
hdulist = pyfits.open("VDGC_catalog_pPXF.fits")
catalog= hdulist[1].data[0]
zerr = []
verr = []
#loop to fill zerr with actual values
for i in range(0, len(catalog)):
if catalog[3][i] == 'GC' and catalog[4][i] == 'N' and catalog[10][i] == 1:
zerr.append(catalog[9][i])
for i in range(0, range(zerr)):
verr.append((zerr[i])*299792458
plot.hist(verr, bins = 100, color = "pink")
plt.show()
print "Done."
答案 0 :(得分:0)
(代码太多;不能将其放在评论中)
除了
中缺少的结束括号外for i in range(0, range(zerr)):
verr.append((zerr[i])*299792458
我能想象你要做的事情就是
for zi in zerr:
verr.append(zi*299792458)
并且更加pythonic版本是
verr = [zi*299792458 for zi in zerr]