在python3中,
import urllib.request import requests from pyheatmap.heatmap import HeatMap def main(): # 下载测试数据 url = "https://raw.github.com/oldj/pyheatmap/master/examples/test_data.txt" data=requests.get(url) data1=data.text.split('\n') print(data1) datas=[] for ln in data1: a=ln.split(',') if len(a)!=2: continue a=[int(i) for i in a ] datas.append(a) print(datas) # 开始绘制 hm = HeatMap(datas) # HeatMap画图的数据格式是怎么样的[[],[],[],...] hm.clickmap(save_as="hit.png") # hm.heatmap(save_as="heat.png") hm.heatmap(base=hm.clickmap(),save_as="heat.png") if __name__ == "__main__": main() #这是成功的/