import csv
import urllib.request
from pylab import *
eventurl = "http://data.hisparc.nl/show/source/eventtime/501/2017/1/1/"
data = urllib.request.urlopen(eventurl)
print(data.read())
当我运行代码并打印eventurl中的数据时,终端显示如下:
b"# HiSPARC eventtime histogram source\n#\n# Station: 501\n# Data from 2017-1-1\n#\n# HiSPARC data is licensed under Creative Commons Attribution-ShareAlike 4.0.\n#\n#\n# Please note: the 'bin' is the left bin edge. The width of the bin is 1\n# hour. So bin 0 means between 0:00 and 1:00. Value means the number of\n# events which were measured during 1 hour.\n#\n# This data contains the following columns:\n#\n# bin: time [hour of day]\n# value: number of events [counts]\n#\n#\n# bin\tvalue\n0\t2265\n1\t2354\n2\t2302\n3\t2353\n4\t2369\n5\t2378\n6\t2280\n7\t2411\n8\t2340\n9\t2431\n10\t2353\n11\t2394\n12\t2412\n13\t2470\n14\t2404\n15\t2540\n16\t2492\n17\t2390\n18\t2454\n19\t2404\n20\t2451\n21\t2467\n22\t2471\n23\t2371\n\n"
我们想要的,只是两行的箱子和值。有没有一个代码可以帮助我们摆脱其余的,并使它易于使用的直方图的数字?你知道吗
输出:
使用Python regex
re
模块输出:
相关问题 更多 >
编程相关推荐