Python3
我需要用这个数据网站绘制8月3日到8月10日的臭氧时间序列。我需要把数据“缝合”在一起。你知道吗
http://skywatch.colorado.edu/data/ozone_18_09_03.dat 所以现在我有
pre= 'http://skywatch.colorado.edu/data/ozone_18_09_0'
ozone = []
utc = []
dates = np.arange(3,10,1)
for date in dates:
url = pre + dates[i] + ".dat"
lines = urllib.request.urlopen(url).readlines()
for line in lines: #for x number of times (however many lines appear in the dataset)
entries = line.decode("utf-8").split("\t")
if entries[0][0] != ';': #if there are entries that do not have a semicolon
utc.append(float(entries[0][0:2]) + \
float(entries[0][3:5])/60. + \
float(entries[0][6:8])/3600.)
#converts the UTC time variable into a float and adds it to the list 'utc'
ozone.append(float(entries[1]))
当我试着运行这个时,我得到了一个错误
--->;9 url=pre+日期[i]+“.dat”
TypeError:必须是str,而不是数字.int32 注意如何处理这个问题
我认为您可能需要显式地转换数字.int32对象到字符串,因为numpy很可能没有为
other: str
定义__add__(self, other)
。你知道吗另外,您使用变量
date
在dates
中迭代,因此您可以使用如下内容:相关问题 更多 >
编程相关推荐