1. python中的优先权队列,priorityqueue用法:数字越小,表示优先级越高,越早被拿出
from queue import Queue
from queue import PriorityQueue
prioqueue=PriorityQueue()
prioqueue.put((1,‘hahaha‘))
prioqueue.put((5,‘ustc‘))
prioqueue.put((2,‘nwsuaf‘))
prioqueue.put((3,‘tsinghua‘))
prioqueue.put((6,‘peking‘))
prioqueue.put((4,‘zhejiang‘))
while prioqueue:
print (prioqueue.get_nowait())
2 . matplotlib画图,显示各种颜色,在对应位置上画上函数值,控制坐标轴范围,在图上写字
import pylab as pl import matplotlib x=[10,20,11,12,15,25] y=[3,6,9,8,7,4] co=[1,2,3,4,5,6] fig1=pl.figure() cm=pl.get_cmap("RdYlGn") for i in range(0,len(x)): pl.plot(x[i],y[i],‘o‘,color=cm(co[i]*1.0/6)) pl.text(x[i],y[i],str(y[i])+‘*‘,color=‘red‘) pl.xlim(0,45) pl.title(‘cluster graph ‘) pl.show()
原文:http://www.cnblogs.com/yanzl/p/4986356.html