随笔分类 -  Python学习

摘要:昨晚笔试了金山WPS的测试开发卷,做个笔记(但不是答案,只是我的想法),关于文件和字符串的处理正在写入与完善至上一篇的博客中,现在题目如下:1.使用脚本语言删除E:\abc目录下的所有文件: 利用os.path.exists()判断E:\abc目录是否存在,如果存在利用shutil.rmtree级... 阅读全文
posted @ 2015-05-21 10:32 Key_Ky 阅读(3073) 评论(0) 推荐(0)
摘要:转:http://l90z11.blog.163.com/blog/static/187389042201312153318389/python中对文件、文件夹的操作需要涉及到os模块和shutil模块。创建文件:1) os.mknod("test.txt") 创建空文件2) open("test.... 阅读全文
posted @ 2014-05-26 20:11 Key_Ky 阅读(399) 评论(0) 推荐(0)
摘要:Python字典操作与遍历:1.http://www.cnblogs.com/rubylouvre/archive/2011/06/19/2084739.html2.http://5iqiong.blog.51cto.com/2999926/806230Python集合操作:1.http://blog.csdn.net/business122/article/details/7541486 阅读全文
posted @ 2014-03-21 21:37 Key_Ky 阅读(249) 评论(0) 推荐(0)
摘要:Python目录操作os和os.path模块os.listdir(dirname):列出dirname下的目录和文件os.getcwd():获得当前工作目录os.curdir:返回但前目录('.')os.chdir(dirname):改变工作目录到dirnameos.path.isdir(name):判断name是不是一个目录,name不是目录就返回falseos.path.isfile(name):判断name是不是一个文件,不存在name也返回falseos.path.exists(name):判断是否存在文件或目录nameos.path.getsize(name):获得文 阅读全文
posted @ 2014-03-19 23:24 Key_Ky 阅读(221) 评论(0) 推荐(0)
摘要:字符串在Python内部的表示是unicode编码,因此,在做编码转换时,通常需要以unicode作为中间编码,即先将其他编码的字符串解码(decode)成unicode,再从unicode编码(encode)成另一种编码。decode的作用是将其他编码的字符串转换成unicode编码,如str1.... 阅读全文
posted @ 2014-03-18 20:18 Key_Ky 阅读(1795) 评论(0) 推荐(0)
摘要:层次聚类关键方法#coding:UTF-8#Hierarchical clustering 层次聚类from E_distance import Euclidean_distancefrom yezi import yeziclass bicluster: def __init__(self, vec, left=None,right=None,distance=0.0,id=None): self.left = left self.right = right #每次聚类都是一对数据,left保存其中一个数据,right保存另一个 self.v... 阅读全文
posted @ 2013-11-24 23:12 Key_Ky 阅读(17703) 评论(2) 推荐(2)
摘要:#coding: UTF-8import pearson_distancefrom pearson_distance import pearson_distancefrom math import sqrtimport random def print_matchs(matchs) : for i in range(len(matchs)) : print i , '---->', for item in matchs[i] : print item, print print '-'*20 def kme... 阅读全文
posted @ 2013-11-16 12:24 Key_Ky 阅读(2263) 评论(2) 推荐(0)