
python
Cedric_h
0.0
展开
-
python 完美解决使用Matplotlib中文乱码问题
如果python使用matplotlib做数据可视化时中文出现乱码,可以使用以下办法进行解决:plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签plt.rcParams['axes.unicode_minus'] = False # 用来正常显示符号完整例子#Matplotlib applicationimport m...原创 2019-05-02 04:49:40 · 974 阅读 · 0 评论 -
Python定时任务sched和多线程Timer用法示例对比
一、sched的定时任务from sched import *from time import *def print_time(msg="default"): print("当前时间",time(),msg)s = scheduler(time,sleep)print(time())s.enter(5,1,print_time,("延迟5秒,优先级1",))s.enter...原创 2019-04-29 22:53:36 · 1800 阅读 · 0 评论 -
python使用多线程threading解决sched的阻塞问题
import datetimeimport schedimport threadingimport timedef init(): global s s = sched.scheduler(time.time,time.sleep)def job1(): print("i am working in job1")def job2(): print...原创 2019-04-29 23:41:02 · 3302 阅读 · 2 评论 -
python中实现K-Means聚类算法
聚类问题是数据挖掘的基本问题,它的本质是将n 个数据对象划分为k个聚类,以便使得所获得的聚 类满足以下条件:同一聚类中的数据对象相似度较 高;不同聚类中的对象相似度较小。它的基本思想是以空间中k个点为中心,进行聚类 ,对最靠近他们的对象归类。通过迭代的方法,逐 次更新各聚类中心的值,直至得到最好的聚类结果 次更新各聚类中心的值,直至得到最好的聚类结果 。**算法的基本步骤**第一步:...原创 2019-06-02 02:35:05 · 589 阅读 · 0 评论