
Python 学习笔记
Live-and-Learn
这个作者很懒,什么都没留下…
展开
-
Python: read/write excel
# 读写2003 excelimport xlrdimport xlwt# 读写2007 excelimport openpyxldef write03Excel(path): wb = xlwt.Workbook() sheet = wb.add_sheet("2003测试表") value = [["名称", "价格", "出版社", "语言"], [...转载 2018-03-09 10:42:36 · 429 阅读 · 0 评论 -
Python:闭包
1,使用闭包def countdown(n): def next(): nonlocal n r=n n-=1 return r return nextnext=countdown(1000000)while True: v=next() # print(v) if not v: break...原创 2018-02-24 09:23:15 · 214 阅读 · 0 评论 -
Python: 用yield来构造递归函数
1 问题在哪??def getflatten(lists): for s in lists: if isinstance(s,list): for item in getflatten(s): yield item else: yield itemitems=[[1,2,...原创 2018-02-24 22:02:03 · 1789 阅读 · 1 评论 -
Python: yield与协程
1.没有显示结果是怎么回事?import os,fnmatch@coroutinedef find_files(target): while True: topdir,pattern=(yield) for path,dirname,filelist in os.walk(topdir): for name in filelis...原创 2018-02-25 08:48:25 · 436 阅读 · 0 评论 -
Python:matrix
numpy模块中的矩阵对象为numpy.matrix,包括矩阵数据的处理,矩阵的计算,以及基本的统计功能,转置,可逆性等等,包括对复数的处理,均在matrix对象中。 class numpy.matrix(data,dtype,copy):返回一个矩阵,其中data为ndarray对象或者字符形式;dtype:为data的type;copy:为bool类型。>>> a = np....转载 2018-03-26 22:36:02 · 1145 阅读 · 0 评论 -
Python:the usage of argparse
16.4. argparse — Parser for command-line options, arguments and sub-commandsNew in version 3.2.Source code: Lib/argparse.pyTutorialThis page contains the API reference information. For a more gentle i...转载 2018-05-04 08:30:21 · 836 阅读 · 0 评论 -
Python:the meaning of parameter in pandas.reade_csv and write_csv
pandas.read_csv参数整理 读取CSV(逗号分割)文件到DataFrame也支持文件的部分导入和选择迭代更多帮助参见:http://pandas.pydata.org/pandas-docs/stable/io.html参数:filepath_or_buffer : str,pathlib。str, pathlib.Path, py._path.local.LocalPath or a...转载 2018-05-04 10:51:46 · 186 阅读 · 0 评论 -
Python: data normalization
method of data normalization点击打开链接转载 2018-05-04 19:29:11 · 1381 阅读 · 0 评论