Python笔记

524 阅读2分钟

书籍

《利用Python进行数据分析》

gdb使用清单

www.jianshu.com/p/fb5f791fc…

命令 解释
break 或 b 设置断点 设置断点
continue 或 c 继续执行程序
list 或 l 查看当前行的代码段
step 或 s 进入函数
return 或 r 执行代码直到从当前函数返回
exit 或 q 中止并退出
next 或 n 执行下一行
pp 打印变量的值
help 帮助

glob模块

glob.glob(pathname, *, recursive=False) 返回所有匹配的文件列表

Return a possibly-empty list of path names that match pathname, which must be a string containing a path specification. pathname can be either absolute (like /usr/src/Python-1.5/Makefile) or relative (like ../../Tools//.gif), and can contain shell-style wildcards. Broken symlinks are included in the results (as in the shell). Whether or not the results are sorted depends on the file system.
If recursive is true, the pattern “**” will match any files and zero or more directories, subdirectories and symbolic links to directories. If the pattern is followed by an os.sep or os.altsep then files will not match.
Changed in version 3.5: Support for recursive globs using “**”.

glob.iglob(pathname, *, recursive=False)返回一个生成器

Return an iterator which yields the same values as glob() without actually storing them all simultaneously.

glob.escape(pathname) new in version 3.4

boto3模块

用于对象化AWS云服务,以进行相应的操作。先声明所用服务,再进行具体的操作。注意需要在~/.aws/credentials中先存入验证信息。

Dask并行模块

主要为数据分析中提供并行能力

pydash

The kitchen sink of Python utility libraries for doing “stuff” in a functional way. Based on the Lo-Dash Javascript library.

提供一些函数化编程能力。

pydash.flatten

将list中的单层元素进行提取

pydash.flatten_deep

将list中的所有元素,递归地进行提取

import的循环引用问题

本质:工程架构上设计不合理,或开发不规范导致
现象:出现import error, 明明有此函数或类,但是还是会报错
原理:

import执行过程当我们import一个文件时,python会首先去查找这个文件之前是否被import过,如果这个文件之前有被import过,就不会重新再import一次。所以如果A模块 代码里import了B模块,并且B模块里又import了A模块,python的执行顺序会变成这样:开始执行模块A当A执行到import B的地方,则停止执行A模块后面的代码,转而开始执行B模块的代码当B模块从头执行到import A的地方时,python此时并不会回过头去接着执行A剩余的代码,而且将A模块在中断前已经初始化的属性全加载到B模块中
作者:dacaoxin
链接:www.zhihu.com/question/19…
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。