摘要: #coding=utf-8__author__ = 'sun'from numpy import *import operatordataSet=array([[1.0,1.1],[1.0,1.0],[0,0],[0,0.1]])labels=['A','A','B','B']def classify0(inX,dataSet,labels,k): dataSetSize=dataSet.shape[0] diffMat=tile(inX,(dataSetSize,1))-dataSet#两个矩阵相减 sqDiff 阅读全文
posted @ 2013-09-22 16:50 yufenghou 阅读(187) 评论(0) 推荐(1)
摘要: #coding=utf-8import cPickle as pshoplistfile='shoplist.data'shoplist=['apple','mango','carrot']f=file(shoplistfile,'w')p.dump(shoplist,f)f.close()del shoplistf=file(shoplistfile)storedlist=p.load(f)print storedlist 阅读全文
posted @ 2013-09-22 10:19 yufenghou 阅读(163) 评论(0) 推荐(0)
摘要: #coding=utf-8poem='''\Programming is funWhen the work is doneif you wanna make your work also fun: use Python!'''f=file('poem.txt','w')f.write(poem)f.close()f=file('poem.txt')while True: line=f.readline() if len(line)==0: break print line,f.close() 阅读全文
posted @ 2013-09-22 09:56 yufenghou 阅读(173) 评论(0) 推荐(0)
摘要: #coding=utf-8class SchoolMember: def __init__(self,name,age): self.name=name self.age=age print 'SchoolMember:%s' %self.name def tell(self): print "Name:'%s' Age:'%s'"%(self.name,self.age)class Teacher(SchoolMember): def __init__(self,name,age,salary): Sch... 阅读全文
posted @ 2013-09-22 09:44 yufenghou 阅读(155) 评论(0) 推荐(0)
摘要: import mathimport osimport time__author__ = 'sun'source=['/home/sun/byte','/home/sun/bin']target_dir='/home/sun/backup/'target=target_dir+time.strftime('%Y%m%H%M%S')+'.zip'zip_command="zip -qr '%s' %s" %(target,''.join(source) 阅读全文
posted @ 2013-09-18 14:40 yufenghou 阅读(142) 评论(0) 推荐(0)
摘要: 安装的是autocompletehttp://cx4a.org/software/auto-complete/是bz2格式压缩的 下载后 在终端输入命令tar -xjvf auto-complete-1.3.1.rar.bz2mvauto-complete-1.3.1 ~/.emacs.d//.emacs.d是emacs默认安装插件的目录进入 ~/.emacs.d/auto-complete-1.3.1makemake install 提示你安装位置 为/home/sun/.emacs.d/接着就会提示安装成功 提示你添加 命令到.emacs 文件 //.eamcs是emacs默认的配置文.. 阅读全文
posted @ 2013-09-17 18:03 yufenghou 阅读(308) 评论(0) 推荐(0)
摘要: 首先安装emacs然后下载yasnippet-bundle-0.6.1c.el.tgz解压在~/.emacs.d/文件夹下新建一个文件plug,一般是新建一个plugins但是我到下面有这个文件夹了,就不再创建了将上一步解压得到到文件mv到plug下面进入~。如果这个文件夹下面有.emacs文件那么就打开,如果没有就创建一个在这个文件当中添加下面两句话(add-to-list 'load-path "~/.emacs.d/plug")(require 'yasnippet-bundle)保存,启动emacs原来安装到时候我把路劲前面多了一个空格。没有配上 阅读全文
posted @ 2013-09-17 17:31 yufenghou 阅读(323) 评论(0) 推荐(0)
摘要: 1 ab={ 2 'Swaroop' :'swaroopch@bytoofpython.info', 3 'Larry' :'larry@wall.org', 4 'Matsumoto' :'matz@ruby-lang.org', 5 'Spammer' :'spammer@hotmail.com' 6 } 7 print("Swaroop's address is %s"%ab['Swaroop']) 8 ab[' 阅读全文
posted @ 2013-09-17 10:42 yufenghou 阅读(112) 评论(0) 推荐(0)
摘要: shoplist=['apple','mango','carrot','banana']print('i have',len(shoplist),'items to purchase.')print('These items are:')for item in shoplist: print(item)print('\nI also have to buy rice.')shoplist.append('rice')print('My shop 阅读全文
posted @ 2013-09-17 09:55 yufenghou 阅读(130) 评论(0) 推荐(0)
摘要: strcat是会改变原来的字符型数组的值的。#include#include#includevoid main(){ char a[20]="sun"; char b[20]="jie"; char *c; c=strcat(a,b); printf("%s\n",a);} 阅读全文
posted @ 2013-09-12 14:31 yufenghou 阅读(143) 评论(0) 推荐(0)