def get_highs():
atlTemps = open("tempsAtlanta2015.txt")
highs = []
highs = split_data(atlTemps, highs, 2)
atlTemps.close()
return highs
def split_data(lst, lst2, num):
for i in lst:
data = i.split(",")
lst2.append(data[num])
return lst2
def main():
highs = get_highs()
print(max(highs))
main()
Run Code Online (Sandbox Code Playgroud)
我将这些功能从我的主程序中取出来进行故障排除,我似乎遇到了使用max()的问题.在文本文档中,我从max()返回的最大数字中提取信息应该是100但是它返回99.我可以索引100,所以我确定100列在包含中.任何帮助将非常感激!
这是文本文件的一部分,信息存储为 [month, day, high, low]
7,29,99,76
7,30,98,76
7,31,96,73
8,1,93,71
8,2,96,68
8,3,98,71
8,4,99,69
8,5,100,71
8,6,90,72
…
Run Code Online (Sandbox Code Playgroud) python ×1