分段错误得到一些分数

时间:2012-11-26 21:00:35

标签: python ipython

del_between=raw_input('Do you want to delete all the points between two points? input "N" or "Y"')
if del_between=="N" or del_between=="n":
    print "You have choosen NOT to delete all the points between two points."
if del_between=="Y" or del_between=="y" :
    print "Please click the first bad point and the last bad point to choose the range of the bad points"
    between_badpoints=ginput(n=2)
    print between_badpoints
    index_between_badpoints=[]
    for i in range(len(between_badpoints)):
         index_between_badpoints.append(int(np.interp(between_badpoints[i][0],jd2,range(len(jd2)))))
    print index_between_badpoints
    index_betweens=[]
    for i in range(sorted(index_between_badpoints)[0],sorted(index_between_badpoints)[1]+1):
         index_betweens.append(i)
    print index_betweens
    for i in index_betweens[::-1]:
         del lat[i],lon[i],time[i],yeardays[i],depth[i],temp[i]

该程序试图删除收集的两点之间的所有点。问题是当我尝试运行该程序时,它会显示分段错误。

当我点击选择点时,它会引发异常“分段错误”,所以我认为问题可能集中在这一行'between_badpoints = ginput(n = 2)'。但我不明白为什么这是错的

(我在同一个程序中使用了这个'ginput'命令并且运行良好,然后我删除了ginput变量并再次使用它,它就无法工作了。)

1 个答案:

答案 0 :(得分:1)

我已经弄清楚了。这是我第二次在这个程序中使用ginput,但是我没有创建一个新的数字。在添加'fig = plt.figure()'行后,每一步都顺利。可能每个数字只能使用一次ginput。