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