摘要: 1. isdigit() 判断字符串内容是否全部为数字。是True;否False。2. s.isalpha() 测试s中所有的字符是否全是字母。 3. s.isalnum() 测试s中所有的私服是否全为数字或字母。eg: 4. s.istitle() 测试s中是否所有的词都是首字母大写。eg: 5. count() 判断字串中出现特定字串的次数。eg: s = '123 345 123 34' s.count('123') #结果是26.chr() ascii码转变为字符。7.ord() 字符转变为ascii码。eg: 8.upper() 把字串全部... 阅读全文
posted @ 2012-09-25 23:58 jihite 阅读(630) 评论(0) 推荐(1) 编辑
摘要: 亲爱的各位获奖的代表们: 大家上午好! 首先向大家表示祝贺,因为新东方有三万名员工、老师和管理者,我们在座的三百多位,平均每一位代表了差不多一百位员工,也就是说你们是百里挑一或者百人挑一挑出来的新东方的优秀代表。正是因为大家的勤奋、努力、坚持,使大家获得这样的荣誉。我也希望在座的各位代表,明年我们在 阅读全文
posted @ 2012-09-07 16:55 jihite 阅读(760) 评论(3) 推荐(3) 编辑
摘要: 定义字典 dic = {'a':"hello",'b':"how",'c':"you"}方法一:for key in dic: print key,dic[key] print key + str(dic[key])结果: a hello ahello c you cyou b how bhow细节:print key,dic[key],后面有个逗号,自动生成一个空格print key + str(dic[key]),连接两个字符串,用的是加号,直接输出,中间不加逗号方法二:for (k 阅读全文
posted @ 2012-09-05 23:42 jihite 阅读(30535) 评论(0) 推荐(1) 编辑
摘要: 正则表达式中,group()用来提出分组截获的字符串,()用来分组import rea = "123abc456"print re.search("([0-9]*)([a-z]*)([0-9]*)",a).group(0) #123abc456,返回整体print re.search("([0-9]*)([a-z]*)([0-9]*)",a).group(1) #123print re.search("([0-9]*)([a-z]*)([0-9]*)",a).group(2) #abcprint re.search 阅读全文
posted @ 2012-08-20 22:37 jihite 阅读(52733) 评论(0) 推荐(10) 编辑
摘要: 缘起看到这样的数据:Marek Čech、Beniardá怎样变成相对应的ascii码呢解决import unicodedatas = u"Marek Čech" #(u表示是unicode而非 ascii码,不加报错!)line = unicodedata.normalize('NFKD',s... 阅读全文
posted @ 2012-08-16 22:31 jihite 阅读(26122) 评论(0) 推荐(0) 编辑
摘要: import osimport os.pathrootdir = “d:\data” # 指明被遍历的文件夹for parent,dirnames,filenames in os.walk(rootdir): #三个参数:分别返回1.父目录 2.所有文件夹名字(不含路径) 3.所有文件名字 for dirname in dirnames: #输出文件夹信息 print "parent is:" + parent print "dirname is"... 阅读全文
posted @ 2012-08-14 22:12 jihite 阅读(123593) 评论(8) 推荐(5) 编辑
摘要: 一 创建目录1.mkdir dir1 dir2 (可以同时建多个)2.指定路径下:mkdir D:/data/hello (D:/data路径下创建目录hello)3.在指定路径不存在时,利用参数 -p ,可同时创建不存在的路径: eg:假如"D:/excel/" 路径不存在,利用 mkdir -p... 阅读全文
posted @ 2012-08-13 20:49 jihite 阅读(884) 评论(0) 推荐(0) 编辑
摘要: 引 字典,形如 dic = {'a':1 , 'b':2 , 'c': 3},字典中的元素没有顺序,所以dic[0]是有语法错误的。并且不可以有重复的键值,所以 dic.add['c'] = 4后,字典变成 {'a':1 , 'b':2 , 'c': 4}. 待解决问题 如何根据需要可以根据“键”或 阅读全文
posted @ 2012-08-07 22:15 jihite 阅读(162632) 评论(0) 推荐(8) 编辑
摘要: 案例: ### 1 ### 结果 ### 2 ### 结果 这里注意两点: 1. if str.find('23'): 此时默认为 str.find('23') != 0: 2. find()函数找不到时返回为-1。 经查阅得知其用法: 函数原型:find(str, pos_start, pos_e 阅读全文
posted @ 2012-08-06 21:09 jihite 阅读(140253) 评论(5) 推荐(0) 编辑
摘要: 1.打开文件 filename,从里面读东西f = file("filename","r")注意:或读'r'是默认的参数,因此可以省略参数:f = file("finename")文件操作file()和open()是一样的,因此可以互换:f = open("filename")逐行读入 for line in f:读一行:line = f.readline() 这样回把最后的换行符(假设有)读入,去(即等价于操作:line = line[:-1] 或 line = line.strip(" 阅读全文
posted @ 2012-07-29 19:15 jihite 阅读(2317) 评论(0) 推荐(0) 编辑