__author__ = 'Administrator'
import codecs def blocks(file, size=65536): while True: b = file.read(size) if not b: break yield b with codecs. open('h:...
分类:
编程语言 时间:
2014-10-30 10:54:09
阅读次数:
166
如何生成斐波那契數列
斐波那契(Fibonacci)數列是一个非常简单的递归数列,除第一个和第二个数外,任意一个数都可由前两个数相加得到。用计算机程序输出斐波那契數列的前 N 个数是一个非常简单的问题,许多初学者都可以轻易写出如下函数:
清单 1. 简单输出斐波那契數列前 N 个数
def fab(max):
n, a, b = 0, 0, 1
while n ...
分类:
编程语言 时间:
2014-10-30 10:20:44
阅读次数:
252
如果可迭代的对象的所有元素全部非空(或者空迭代对象),就返回True。这个函数主要用来判断列表、元组、字典等对象是否有空元素,比如有10000个元素的列表,如果没有提供此函数,需要使用循环来实现,那么计算速度会比较慢。这个函数的等同下面代码的功能:def all(iterable): for element in iterable: if not element: ...
分类:
编程语言 时间:
2014-10-30 09:35:32
阅读次数:
213
题目链接 ~~ http://acm.hdu.edu.cn/showproblem.php?pid=2571题意很简单,就是求左上角到右下角的最大值。刚开始忘了初始化。。WA好几回。。代码:: 1 #include 2 #include 3 using namespace std; 4 #def.....
分类:
其他好文 时间:
2014-10-29 21:24:29
阅读次数:
187
该脚本的功能是卸载android手机中安装的所有第三方应用,主要是使用adb shell pm、adb uninstall 命令,所以使用的前提是需要配好adb的环境变量,下面上代码: 1 #!/usr/bin/env python 2 3 import os 4 5 def uninstall.....
分类:
移动开发 时间:
2014-10-29 16:40:50
阅读次数:
160
假如你的项目里有这样一个文件mylib.py,文件里写了很多个方法供外面的人调用def add(x,y): return x+ydef division(x,y): return x/ydef mutiply(x,y): return x*ydef subtract(x,y): ...
分类:
编程语言 时间:
2014-10-29 16:37:21
阅读次数:
183
1.把一个文件里面所有包含 abc 的行里面的 abc 替换成 def,然后输出第一列和第三列cat abc.txt | grep abc | sed 's/abc/def/g' | awk '{print $1,$3}'awk '$0 ~ /abc/ {gsub("abc", "def", $0)...
分类:
系统相关 时间:
2014-10-29 16:29:55
阅读次数:
183
最小堆算法: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 10 using namespace std; 11 12 #def...
分类:
编程语言 时间:
2014-10-29 14:40:51
阅读次数:
247
方法一:# -*- coding: utf-8 -*-import sysimport osimport stringRCV_LOG = r"d:\c.txt"def get_last_n_lines(logfile, n): n = string.atoi(n) blk_size_ma...
分类:
编程语言 时间:
2014-10-29 12:53:19
阅读次数:
739
code1:object factorial{ def main(args:Array[String])={ println(factorial(args(0).toInt)) } def factorial(x:Int):Int = if (x==0) 1 else x * fa...
分类:
其他好文 时间:
2014-10-29 12:52:22
阅读次数:
176