0
我的代碼讀取從開始到結束:試圖打開外部文本文件在我的主文件
fo = open(BoulderWeatherData.csv, "r")
days=0
precip=0
lines = fo.readline()
listofpercip = []
for lines in fo:
days = days +1
splitting = line.split(",")
precip = precip + float(splitting[4])
listofpercip.append(spliting[4])
avg = round(listpercip/days, 2)
print ("the average rainfall is ", average)
print ("the max amount of rain for one day is:", max(listofpercip))
fname.close()
終端響應:
[email protected]:~/Dropbox$ python3 recitation4.py
Traceback (most recent call last):
File "recitation4.py", line 5, in <module>
fo = open(BoulderWeatherData.csv, "r")
NameError: name 'BoulderWeatherData' is not defined
我想知道什麼是錯的與文件im調用,它被完全調用,並在我的主文件相同的目錄中找到....我不明白爲什麼它需要定義時,所有即時消息正在調用它....
我想出了自己,我犯了一個簡單的錯誤......沒有「」我的文件名..... WOWW – 2014-09-29 20:31:55