- 博客(14)
- 资源 (4)
- 收藏
- 关注
翻译 python中的工程模式
还是看源代码:from __future__ import generatorsimport randomclass Shape(object): def factory(type): if type == "Circle":return Circle() if type == "Square":return Square()
2013-03-29 10:20:15 747
原创 python网络编程
网络连接:import socketprint "creating socket"s = socket.socket(socket.AF_INET , socket.SOCK_STREAM)print "done"print "looking up port number..."port = socket.getservbyname("http","tcp")print
2013-03-25 11:19:33 595
原创 python中对象以及一些函数的应用
看代码:#coding:UTF-8import sysimport inspectdef foo(): passclass Cat(object): def __init__(self,name='kitty'): self.name = name def sayhi(self): print self.nameif __name__ == '__main__':
2013-03-22 22:16:47 458
原创 c内存问题以及简单的一个表
代码如下:#include #include#include#includetypedef int Element;struct LIST;typedef struct LIST *list;struct LIST{ Element x; list next;};#define alloc_list_p malloc(sizeof(struct LIST))cha
2013-03-20 22:44:17 481
原创 c语言文件读写的一个例子
看代码:#include #include#includeint main(){ FILE *input ,*destfile; int t; input = fopen("D:/1.txt","r"); destfile = fopen("D:/2.txt" , "w"); if(input == NULL) { perror("the file is empit
2013-03-19 23:26:24 908
原创 c语言的一个数组翻转
我习惯用for循环,代码如下:#include int main(){ int i=0; int a[]={1,2,3,4,5}; int b[5]; for(i=0;i<=4;i++) { int j = 4-i; b[j]=a[i]; } for(i=0;i<=4;i++) { printf("%d\n",b[i]); } return 0;
2013-03-18 22:44:23 953
原创 c语言产生随机数并排序
#include #include#include#define TRUE 1#define FALSE 0#define N 100int a[N];int i,j;int *get_array(){ static int flag = 1; for(i=0;i<N;i++) { a[i]=rand()%100; for(j=0;j<i;j++){ if(
2013-03-18 22:42:08 9787
原创 python中多线程的一个例子
看代码:import timeimport threadfrom time import ctimedef timer(i,interval): while True: ts="thread:"+str(i)+"-"+str(interval) print ts,ctime() time.sleep(interval)def te
2013-03-11 11:33:51 3445
原创 javascript中apply
在方法中想用到另外一个对象的方法可以用apply:<!-- --> function Person(name ,age) { this.name=name; this.age=age; } function Student(name,age,grade) { Person.apply(this,argum
2013-03-08 11:04:52 745
原创 python爬虫程序
主要是为了记录一些爬虫程序1,最简单网页元素的抓取import urllib2import pprintc=urllib2.urlopen('http://kiwitobes.com/wiki/Programming_language.html')contents=c.read()pprint.pprint(contents)print"-"*60print content
2013-03-07 17:01:28 1920 1
原创 javascript闭包
先看下面函数: var scope="gloal scope"; function checkscope(){ var scope="local scope"; function f(){return scope;} return f(); } console.log(checkscope());
2013-03-07 11:03:09 543
原创 javascript中的函数学习
主要学习一下javascript中函数的使用: console.log("12334"); var b=5; var c=Math.sqrt(b); console.log(c); function distance(x1,y1,x2,y2){ dx=x2-x1; dy=y2-y1; return
2013-03-07 09:59:50 610
原创 我的windows的vim配置
参考配置http://www.cnblogs.com/cecwxf/archive/2012/03/29/2424433.htmlhttp://www.hiadmin.org/code/python-vimset nocompatiblesource $VIMRUNTIME/vimrc_example.vimsource $VIMRUNTIME/mswi
2013-03-05 16:32:37 610
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人