共 91 篇文章 |
|
# Aligned with opening delimiter.foo = long_function_name(var_one, var_two, var_three, var_four)# More indentation included to distinguish this from the rest.def long_function_name( var_one, var_two, var_three, var_four): print(var_one)# Hanging indents should add a level.foo = long_function_name( var_one, var_two, va... 阅206 转0 评0 公众公开 16-10-26 15:50 |
Python PEP 8 简单汇总 · sighingnowPython PEP 8 简单汇总 Published On February 07, 2015.Python 3 不允许混用Tab键和空格来缩进。def munge(input: AnyStr): def munge(sep: AnyStr = None): def munge() -> AnyStr: def munge(input: AnyStr, sep: AnyStr = None, limit=1000):def munge(input: AnyStr=None): def munge(input:... 阅257 转2 评0 公众公开 16-10-26 15:49 |
【已解决】Python中通过csv的writerow输出的内容有多余的空行 | 在路上。csvWriter = csv.writer(outputFp, dialect=''excel'');outputFp.close();#init output file # ''a+'': read,write,append # ''w'' : clear before, then write outputFp = open(gConst[''csvFilename... 阅697 转0 评0 公众公开 16-10-15 17:14 |
Python提供类似于C++ gdb的调试工具pdb,我们可以在Linux下使用pdb在命令行下进行Python程序的调试。Step Over:(Pdb) n #单步执行,next的首字母 Step Into:(Pdb) s #step的首字母 Setp Return:(Pdb) r #return的首字母 Resume:(Pdb) c #continue的首字母 Run to Line:(Pdb) j 10 #运行到地10行,jump的首字母。(Pdb) p param #查看当... 阅773 转0 评0 公众公开 16-09-09 22:47 |
bsr_matrix(arg1, shape=None, dtype=None, copy=False, blocksize=None)Block Sparse Row matrix The Block Compressed Row (BSR) format is very similar to the Compressed Sparse Row (CSR) format.lil_matrix(arg1, shape=None, dtype=None, copy=False)Row-based linked list sparse matrix This is an efficient structure for constru... 阅1708 转0 评0 公众公开 16-07-09 11:22 |
IPython、Notebook、qtconsole使用教程。%run test.py 直接运行python脚本%pwd: 显示当前工作目录。%cd: 切换工作目录。%bookmark: 工作目录书签使用快捷键。ctrl+u 删除整行(光标在最后)ctrl+k 删除整行(光标在最前)ctrl+l 清空屏幕ctrl+c 中止运行程序ctrl+e 跳转到最后ctrl+a 跳转到第一行(与Windows热键冲突,是全选)ctrl+r 反向搜索... 阅813 转1 评0 公众公开 16-06-14 18:24 |
(拷贝组合对象,不拷贝子对象)>>> import copy>>> a = [[1, 2],[5, 6], [8, 9]]>>> b = copy.copy(a) # 浅拷贝得到b>>> c = copy.deepcopy(a) # 深拷贝得到c>>> print(id(a), id(b)) # a 和 b 不同139832578518984 139832578335520>>> for x, y in zip(a, b): # a 和 b 的子对象相同.... 阅104 转0 评0 公众公开 16-01-28 09:09 |
用pyinstaller把python脚本生成.exe文件一、下载pyinstallerpip install pyinstaller二、生成.exe文件1.在命令框,把文件夹转到目标脚本所在的文件夹(e.g. cd /d E:/python)。②.dist文件夹:此文件夹下有你想要的.exe文件,可以直接在命令框执行③.build文件夹:此文件夹无用,可以删除。=================================================... 阅341 转3 评0 公众公开 16-01-25 13:04 |
将Python脚本文件包装成可执行文件。将Python脚本文件包装成可执行文件,其目的有二:NOTE: 目前该工具只支持到Python2.7, 对于Python3而言,必须借助另外一个工具:cx_freeze.D:\temp>setup.py py2exe 运行之后,会在我当前运行的目录下(D:\temp)默认生成dict目录,里面的文件如下:如本例中: Python27.dll 3、.pyd文件,它们是已编译的扩展... 阅954 转2 评0 公众公开 16-01-22 19:15 |
Python函数参数默认值的陷阱和原理深究 · cenalulu''s Tech Blog.本文将介绍使用mutable对象作为Python函数参数默认值潜在的危害,以及其实现原理和设计目的陷阱重现。之后所有的函数调用时,如果参数不显示的给予赋值,那么所谓的参数默认值不过是一个指向那个在compile阶段就已经存在的对象的指针。如果参数的默认值是一个不可... 阅44 转0 评0 公众公开 16-01-22 18:03 |