【发布时间】:2021-04-22 15:16:42
【问题描述】:
有人可以帮忙解决这个问题吗? 我在 Python 上遇到了一个错误,如下面的 ss。
这是我的代码:
longitude_list = []
for i in range(2, maxRow+1):
country = sheet.cell(i,7).value
if country == "United States":
longitude = sheet.cell(i,6).value
longitude_list.append(longitude)
median = np.median(longitude_list)
for i in range(2, maxRow+1):
country = sheet.cell(i,7).value
if country == "United States":
if median.any() > longitude_list:
if pdsCnt[2] < allocation:
sheet.cell(i,25).value = pds[2]
pdsCnt[2]+=1
else:
pdsCnt[3] < allocation
sheet.cell(i,25).value = pds[3]
pdsCnt[3]+=1
print(median)
我只是想用这个 'if median.any() > longitude_list:' 创建条件,但是它返回错误。
【问题讨论】:
-
你想用这个 if 语句实现什么?您正在使用 longitude_list 的中位数并检查它是否小于 longitude_list?您的预期行为是什么?
-
这是一个 LibreOffice Calc 宏吗?如果是这样,一个示例电子表格将有助于使其正常工作。
-
Other 可以给出更有用的答案,如果你澄清你想在代码后面做什么,特别是条件语句。
-
Please don't post error messages as screenshots。相反,请编辑您的答案以将错误消息包含为引用文本。
标签: python error-handling valueerror