摘要: % 格式 tpl = "i am %s" % "alex" tpl = "i am %s age %d" % ("alex", 18) tpl = "i am %(name)s age %(age)d" % {"name": "alex", "age": 18} tpl  阅读全文
posted @ 2018-07-25 11:21 黄瓜不是好瓜 阅读(142) 评论(0) 推荐(0) 编辑
摘要: import hashlib def md5(arg): ooo = hashlib.md5(bytes('qazwsx',encoding='utf-8')) ooo.update(bytes('arg',encoding='utf-8')) return ooo.hexdigest() def 阅读全文
posted @ 2018-07-25 10:32 黄瓜不是好瓜 阅读(467) 评论(0) 推荐(0) 编辑
摘要: 查看模块路径 import re import sys for i in sys.path: print(i) 用于提供系统级别的操作: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 os. 阅读全文
posted @ 2018-07-24 12:58 黄瓜不是好瓜 阅读(102) 评论(0) 推荐(0) 编辑
摘要: import re re.match() #从头匹配 re.search() #在字符串的全局匹配,匹配第一次出现的符合规则的字符串 re.findall() #将匹配到的所有内容都放置在一份个列表中 re.split() re.sub() 阅读全文
posted @ 2018-07-23 15:34 黄瓜不是好瓜 阅读(211) 评论(0) 推荐(0) 编辑
摘要: re.match('com','ww').group() group() 为方法 re.match('com','ww',re.I).group() group() 返回被re匹配的字符串 start() 返回匹配开始的位置 end() 返回匹配结束的位置 span() 返回一个元组包含匹配(开始、 阅读全文
posted @ 2018-07-22 00:20 黄瓜不是好瓜 阅读(79) 评论(0) 推荐(0) 编辑
摘要: \d 匹配任何十进制数,它相当于类[0-9] \D 匹配任何非数字字符;它相当于类[^0-9] \s 匹配任何空白字符;它相当于类[\t\n\r\f\v] \S 匹配任何非空白字符;它相当于类[^\t\n\r\f\v] \w 匹配任何字母数字字符;它相当于类[a-z A-Z 0-9_] \W 匹配任 阅读全文
posted @ 2018-07-20 15:46 黄瓜不是好瓜 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 正则:它本身是很多语言都有的,本身是一门语言,根据字符串匹配寻找的一门工具,python通过接口调用方式,使用re模块 普通字符 import re re.findall ('gg','fdsfdsggcvcssgg') 返回列表的格式 应该输出结果:['gg','gg'] 'abcd'.find( 阅读全文
posted @ 2018-07-06 15:00 黄瓜不是好瓜 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 装饰器举例 def outer (func): def inner(): print('hello') return func() print('end') return r return inner @outer 写上这个@ 符号就代表着使用装饰器 def f1(): print('f1') de 阅读全文
posted @ 2018-06-28 17:10 黄瓜不是好瓜 阅读(66) 评论(0) 推荐(0) 编辑
摘要: def f4(a1,a2): print(a1,a2) if a1>1000: return #a1=0;a2=1;a3=1 #a1=1;a2=1;a3=2 a3 = a1 + a2 f4(a2,a3) f4(0,1) 斐波那契数列第十个数 def f5(depth,a1,a2): print(de 阅读全文
posted @ 2018-06-28 16:05 黄瓜不是好瓜 阅读(63) 评论(0) 推荐(0) 编辑
摘要: li[33,4,10,2] for i in range(len(li)-1): current = li[i] next_value = li[i+1] print(li[i]) fi li[i]>li[i+1]: temp = li[i] li[i] = li[i+1] li[i+1] = te 阅读全文
posted @ 2018-06-28 11:17 黄瓜不是好瓜 阅读(99) 评论(0) 推荐(0) 编辑