【发布时间】:2014-09-29 20:19:33
【问题描述】:
我的代码从头到尾:
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()
终端响应:
user@cu-cs-vm:~/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
我想知道我调用的文件有什么问题,它被准确地调用并且与我的主文件在同一目录中找到....我不明白为什么在我做的所有事情时都需要定义它正在调用它....
【问题讨论】:
-
我自己想通了,我犯了一个简单的错误...没有“”我的文件名.....哇
标签: python-3.x text-files