Python used a little knowledge memo

Source: Internet
Author: User

1. The priority queue in Python, priorityqueue usage: the smaller the number, the higher the priority, the sooner it is taken out

 fromQueueImportQueue fromQueueImportPriorityqueueprioqueue=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')) whilePrioqueue:Print(Prioqueue.get_nowait ())

2. Matplotlib drawing, displaying various colors, drawing function values in corresponding positions, controlling the range of axes, writing on diagrams

ImportPylab as PLImportMatplotlibx=[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") forIinchRange (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 ()

Python used a little knowledge memo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.