python中的单元测试可以使用doctest,unittest完成
1.doctest的使用
(1)写入程序如下(cubetest.py):
#!/usr/bin/python
def cube(x):
"""
cube a number and return the result
>>> cube(2)
8
>>> cube(3)
27
>>> cube(4)
64...
分类:
编程语言 时间:
2014-05-13 23:33:19
阅读次数:
491
Pat1018代码
题目描述:
There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and return it to an...
分类:
其他好文 时间:
2014-05-13 23:27:04
阅读次数:
582
http://en.wikipedia.org/wiki/Return-to-zeroRZ编码(Return-to-zero
Code),即归零编码。在RZ编码中,正电平代表逻辑1,负电平代表逻辑0,并且,每传输完一位数据,信号返回到零电平,也就是说,信号线上会出现3种电平:正电平、负电平、零电平:...
分类:
其他好文 时间:
2014-05-13 22:54:15
阅读次数:
3085
题目:Given an input string, reverse the string word
by word.For example,Given s = "the sky is blue",return "blue is sky
the".Clarification:What constitu...
分类:
其他好文 时间:
2014-05-13 22:45:04
阅读次数:
317
效果图:
程序分析:
初始化GameLayer场景触摸,背景、音乐、UI及定时间器
bool GameLayer::init()
{
if (!CCLayer::init()) {
return false;
}
// 开启触摸
this->setTouchEnabled(true);
// 创建数组,需要...
分类:
其他好文 时间:
2014-05-13 07:39:29
阅读次数:
214
Assembly instructions
汇编初步学习
汇编0基础的戳上面,刷一遍,包治百病
%eax寄存器的值与C语言的return的值相对应
(%esp)地址处储存的是函数的返回地址 return address
%esp 栈顶寄存器 保存栈顶指针。
%ebp = boundary between p...
分类:
其他好文 时间:
2014-05-13 06:28:37
阅读次数:
416
#!/usr/bin/envpython#coding:utf8#此脚本为查找递归目录下所有文件匹配的内容importos,sys,tabdefpaths(path):list_path=os.walk(path)all_file=[]forp,d,flinlist_path:forfinfl:pfile=os.path.join(p,f)ifos.path.isdir(pfile):paths(pfile)all_file.append(pfile)returnall..
分类:
编程语言 时间:
2014-05-13 03:49:34
阅读次数:
426
1、当你想并发去执行一段代码,但是还想获取这段代码的返回结果,那么future多线程模式就可以派上用场了,代码实现如下。publicclassClient{
publicDatarequest(){
finalFutureDatafutureData=newFutureData();
newThread(newRunnable(){
@Override
publicvoidrun(){
futureDat..
分类:
编程语言 时间:
2014-05-13 01:29:02
阅读次数:
405
#!/usr/bin/envpython#coding:utf8#随机生成自定义长度密码fromrandomimportchoiceimportstring,pickledefGenPassword(length=8,chars=string.ascii_letters+string.digits):return‘‘.join([choice(chars)foriinrange(length)])defpasslist(r_user,c_user,ip_list,web_list):di..
分类:
编程语言 时间:
2014-05-13 01:25:56
阅读次数:
505
7.1 操作系统接口
Os模块提供主要许多与操作系统交互的函数。
>>> import os
>>> os.getcwd() # Return the current working directory
’C:\\Python31’
>>> os.chdir(’/server/accesslogs’) # Change current working directory
>>> ...
分类:
编程语言 时间:
2014-05-12 23:08:03
阅读次数:
356