
Python
jaygno
新人无解。
展开
-
目录下文件重命名
由于有时候目录下全是一些名字太乱太长的文件名,一两个手动改,多了只能靠脚本了。参数就是目录路径。#!/usr/bin/pythonimport osimport sysdef rename(dir_path): j=0 filename = os.listdir(dir_path) for i in filename: data = os.path.join(dir原创 2017-10-26 10:12:37 · 265 阅读 · 0 评论 -
python yield
def fab(max): n, a, b = 0, 0, 1 while n > for n in fab(5): ... print n ... 1 1 2 3 5有 yield 的函数在 Python 中被称之为 generator(生成器)。在 for 循环执行时,每次循环都会执行 fab 函数内部的代码,执行到 yield b 时,fab 函数就返回一个迭代值,下次迭代时转载 2017-10-26 10:13:20 · 166 阅读 · 0 评论 -
python 后台运行问题
发现python 后台运行会报[Errno 5] Input/output error。启动的时候最好把输出的log重定向一下, 应该是程序在后台运行,退出当前shell,输出引起的异常。可以用nohup启动python有这种问题么,我勒个去。本文出自 “一路风景” 博客,请务必保留此出处http://which.blog.51cto.com/7179876/1411057原创 2017-10-26 10:13:24 · 453 阅读 · 0 评论 -
python3 升级
官网下载源码包3.7参考 http://www.cnblogs.com/devilmaycry812839668/p/9274547.html遇到 Issue 30090: Failed to build these modules: _ctypes 问题 install libffi-dev如果提示版本问题:卸载旧版本,重新安装sudo apt-get remove libffi6...原创 2018-09-06 17:14:18 · 546 阅读 · 0 评论