随笔分类 -  python

入门及数据结构
摘要:如何解两个字符串,是否只是字符位置变换:四种方法。 1、标记位置法,每个都标记,找到后将位置标记位None 2、排序比较法,先把两个字符串拆为列表, 并排序,排序后一个个比较 3、暴力匹配法,将前者所有可能的组合枚举出来,看是否有跟后者匹配的 4、计数比较法,分别计数两个字符串中包含字符的数量,然后 阅读全文
posted @ 2021-05-11 00:35 一二三的三二一 阅读(45) 评论(0) 推荐(0)
摘要:注意,类中的方法,self这个参数是必须的。 >>> class fraction: def __init__(self,top,bottom): self.num = top self.den = bottom def show(): print("%d / %d"%(self.num,self. 阅读全文
posted @ 2021-05-07 09:45 一二三的三二一 阅读(56) 评论(0) 推荐(0)
摘要:1、join的用法 >>> import random >>> def createFunction1(): str1 = [] str2 = 'abcdefghijklmnopqrstuvwxyz ' count = 0 while(count < 27): ch = random.choice( 阅读全文
posted @ 2021-05-06 21:34 一二三的三二一 阅读(55) 评论(0) 推荐(0)