随笔分类 -  python

Python 模块 | multiprocessing
摘要:https://juejin.im/post/5c07b27af265da611b58234c multiprocessing.Process multiprocessing.Queue 阅读全文

posted @ 2020-03-17 17:17 TMatrix52 阅读(118) 评论(0) 推荐(0)

numpy.pad 用法
摘要:https://docs.scipy.org/doc/numpy/reference/generated/numpy.pad.htmlhttps://cugtyt.github.io/blog/2017/11022006.html>>> import numpy as np >>> a = np.a 阅读全文

posted @ 2020-03-01 17:09 TMatrix52 阅读(165) 评论(0) 推荐(0)

collections.defaultdict()
摘要:https://www.cnblogs.com/herbert/archive/2013/01/09/2852843.html 阅读全文

posted @ 2019-11-14 19:57 TMatrix52 阅读(101) 评论(0) 推荐(0)

python 根据两个字段排序, 一个升序, 一个降序
摘要:from collections import Counter c = Counter(input()) l=sorted(c.items(), key=lambda s:(-s[1], s[0])) for i in l[:3]: print(' '.join(map(str, list(i)))) 阅读全文

posted @ 2019-08-25 16:52 TMatrix52 阅读(1093) 评论(0) 推荐(0)

python中yield的用法
摘要: 阅读全文

posted @ 2019-07-30 08:59 TMatrix52 阅读(136) 评论(0) 推荐(0)

用Python提取中文关键词
摘要:如何用Python提取中文关键词? 阅读全文

posted @ 2019-02-14 13:31 TMatrix52 阅读(266) 评论(0) 推荐(0)

Python heapq模块
摘要:注意,默认的heap是一个小顶堆! heapq模块提供了如下几个函数: heapq.heappush(heap, item) 把item添加到heap中(heap是一个列表) heapq.heappop(heap) 把堆顶元素弹出,返回的就是堆顶 heapq.heappushpop(heap, it 阅读全文

posted @ 2018-10-22 13:00 TMatrix52 阅读(139) 评论(0) 推荐(0)

tofile和fromfile数组内建函数
摘要:numpy教程:基本输入输出和文件输入输出Input and output 使用数组的方法函数tofile可以方便地将数组中数据以二进制的格式写进文件。tofile输出的数据没有格式,因此用numpy.fromfile读回来的时候需要自己格式化数据 Note: 1. 读入的时候设置正确的dtype和 阅读全文

posted @ 2018-09-18 16:52 TMatrix52 阅读(552) 评论(0) 推荐(0)

python defaultdict 类型
摘要:http://www.cnblogs.com/youxin/p/3153462.html 阅读全文

posted @ 2018-05-22 16:55 TMatrix52 阅读(95) 评论(0) 推荐(0)

python time 时间处理
摘要:a='2018-03-26 17:20:11' >>> print time.strftime("%Y%m%d", a)Traceback (most recent call last): File "<stdin>", line 1, in <module>TypeError: argument 阅读全文

posted @ 2018-05-17 20:33 TMatrix52 阅读(196) 评论(0) 推荐(0)

Python: locals() 和globals()
摘要:https://www.cnblogs.com/wanxsb/archive/2013/05/07/3064783.html 阅读全文

posted @ 2018-04-23 13:29 TMatrix52 阅读(111) 评论(0) 推荐(0)

python import 其他 package的模块
摘要:https://blog.csdn.net/luo123n/article/details/49849649 http://blog.habnab.it/blog/2013/07/21/python-packages-and-you/ demo project 本文以一个demo project为例 阅读全文

posted @ 2018-03-28 20:00 TMatrix52 阅读(215) 评论(0) 推荐(0)

带列表写入文件出错先 json.dumps
摘要:output = json.dumps(output, ensure_ascii=False).encode('utf-8') 阅读全文

posted @ 2017-12-29 19:24 TMatrix52 阅读(181) 评论(0) 推荐(0)

tarfile — Read and write tar archive files
摘要:参考: https://docs.python.org/2/library/tarfile.html http://www.jianshu.com/p/bbad16822eab #解压文件tarfile.open(filepath, 'r:gz').extractall(inception_pret 阅读全文

posted @ 2017-12-10 17:16 TMatrix52 阅读(145) 评论(0) 推荐(0)

一些稍微复杂的正则表达式
摘要:参考: http://www.jb51.net/shouce/jquery/regexp.html http://www.cnblogs.com/huxi/archive/2010/07/04/1771073.html 1. 数量词的贪婪模式与非贪婪模式 2. 数量词的贪婪模式与非贪婪模式 正则表达 阅读全文

posted @ 2017-12-08 13:31 TMatrix52 阅读(229) 评论(0) 推荐(0)

np.tile语法
摘要:>>> v = np.array([1, 0, 1])>>> vv = np.tile(v,(4,1))>>> print vv[[1 0 1] [1 0 1] [1 0 1] [1 0 1]]>>> 阅读全文

posted @ 2017-11-21 20:54 TMatrix52 阅读(172) 评论(0) 推荐(0)

mac下python安装MySQLdb模块
摘要:参考:http://blog.csdn.net/yelyyely/article/details/41114449 1、调整到anaconda下的python 2、安装有关程序 阅读全文

posted @ 2017-11-15 18:54 TMatrix52 阅读(125) 评论(0) 推荐(0)

virtualenv搭建python3 环境
摘要:参考 1、安装python3 2、创建虚拟环境: 阅读全文

posted @ 2017-11-12 18:23 TMatrix52 阅读(128) 评论(0) 推荐(0)

pandas Dataframe 构造
摘要: 阅读全文

posted @ 2017-11-01 15:00 TMatrix52 阅读(140) 评论(0) 推荐(0)

pandas apply()函数参数 args
摘要:#!/usr/bin/python import pandas as pd data = {'year':[2000,2001,2002,2001,2002],'value':[1.5,1.7,3.6,2.4,2.9]} frame = pd.DataFrame(data) def testfunc(x, str): #第一个参数代表该函数处理的每一个元素,第二个参数args是传入的参数... 阅读全文

posted @ 2017-11-01 14:24 TMatrix52 阅读(8442) 评论(0) 推荐(0)

导航