python challenge 0-10 代码小结

来源:互联网 发布:剪切数据丢失怎么恢复 编辑:程序博客网 时间:2024/06/07 02:14
'''Created on 2012-4-27@author: xxx''''''字符转换方式,配合translate使用string.maketrans(string.lowercase, string.lowercase[2:] + 'ab')查找字符串中特定字符,注意相关正则表达式for i in re.findall(r'[a-z]', s):for i in re.findall(r'[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]', s):判断字符串中是否存在特定字符re.search(r'\d', stri)列表转换为字符串''.join(re.findall(r'(\d*)$', stri))反序列化,序列化为dumpbp = open('banner.p')picklelist = pickle.load(bp)注意一下使用方式''.join(j[0] * j[1] for j in i)zip解压缩zipfile.ZipFile('channel.zip')获得注释cz.getinfo(name + '.txt').commentchr将0-255的整数转换成对应字母,getpixel获得相关位置像素chr(op.getpixel((i, 43))[0])bzip2解压缩bz2.decompress(un)创建图片,设定方式及大小Image.new('1', (500,500))在pic上修改ImageDraw.Draw(pic)画线。first为坐标列表,fill指定画线的颜色draw.line(first, fill = 255)'''
原创粉丝点击