老师,这个方法,只限定了最小必须匹配8位,如果输入20位以上,不会报None
老师,这一课所讲的reduce函数,只能用在遍历求和当中吗?
老师,闭包,内部函数,必须返回外部函数吗?我记得当时说闭包的,时候没有这个要求
老师,实例对象可以调用类方法吗?实例对象拥有类属性、类方法吗?
老师,我查了资料,还是不懂实例对象,类对象,实例方法,类方法的具体区别,用法?麻烦您和我说一下
老师e.args,是什么意思?我知道e,后面为啥要加.args?
def dictionary_reader(filename): """ :param filename: The type of the filename is string, which means users need to input a string type's filename. :return: a list which contain each word in the file """ words_no_punctuation = [] words_less_than_9 = [] try: # open the file and execute the read operation f = open(filename, 'r') # append the each word speratly into a list words = f.readlines() for word in words: words_no_punctuation.append(word.strip()) for word in words_no_punctuation: if len(word) <= 9: words_less_than_9.append(word) # print(len(words_less_than_9)) # This is the test part of the dictionary_reader # Test passd, if length of list equal to 235887 x = '' for word in words_less_than_9: if len(word) > 9: x = False break else: x = True continue if x == False: print("Not all of the len of word in this list, which is less than 9 characters.") else: print("-----Test passed! All words in this list are less than 9 characters-----") if len(words) == 235887: print("-----Test passed! There are 235887 words in the list!-----") else: print("The len of words is not equal to the len of word in the words.txt.") if isinstance(words_less_than_9, list): print("-----Test pssed! The function dictionary_reader will return the all words which len are less than 9 characters in a list!-----") else: print("The return stuff is not the list type.") return words_less_than_9 except BaseException as e: # print the error information when programme meet error # it is easy to help users matain the programme print(e) finally: # make sure the file stream will be closed in any suitation of programme f.close() def word_lookup(): # read file at first # words is a list, and each elements in the words list is a word. words = dictionary_reader('words.txt') sorted_dictionary = [] longest_words = [] possibility_words = [] for word in words: """ every single word in the words list will be sorted by alphabetical. """ word = word.strip() # ensure every single word in the list is lowercase sorted_dictionary.append("".join(sorted(word)).lower()) print(sorted_dictionary)
words.txt WechatIMG945.png
老师您好,这是我写的的两个函数。在word_lookup里面我尝试把文件里面的每一个单子都变成字母排序,但是控制台输出的第一个单词并不是按字母排序去排序的,请问一下这是为什么?
输出在附件里面传上去了,不知道为什么不能够上传图片,抱歉。
谢谢老师
pattern=s=v=re.match(patterns) (v)
这里能够匹配1-99的数字,但是如果我超过了比如101他也会匹配10出来,如何限制长度在两位之间?
如果是在后面加{2}则会报错,老师,这里应当如何处理
pattern='[A-Z][a-z]*'
这里的*号加在那个[]后面表示的就是匹配那个[]的吧,比如如果是
[A-Z]*[a-z]表示的就是[A-Z]中的,是这样吗?老师
老师,添加静态方法跟添加类方法有什么区别吗,感觉两个都是一样的,动态方法我可以理解为为仅对象拥有,但是静态方法跟类方法感觉像是一个东西,他们之间区别具体在哪些方面呢?
老师,我这里去调用这个装饰器,但是后台会报错
time (func): : file=(=) file.write(func.) file.write() file.write(time.asctime()) file.write() e: (e.args) : file.close() (func): (): writelog(func) func() funcin() (): () (): () func1() func2()
老师您好,请问[]和()两个修饰功能中,()仅仅只是进行分组,但不能将分组的东西作为一个整体修饰,需要使用+ * ?等符号去修饰内容出现的特性时,一定要用[]吗?另外,当结束符号前面有?+等,是有限使用? +等符号的规则,然后再做结尾判定是吗?
'^[A-Z][(a-z)*]'; '^[A-Z][(a-z)]*';
既然sum可以替代那这个函数的优势在哪?
老师请问一下是因为最终log里面return了with_logging所以test.__name__打印的是with_logging的名字,可以这样去理解吗?谢谢老师
老师请问一下控制台说time.clock()将会在3.8中被移除,之后的版本应该用什么模块去计算代码运行的时间,谢谢老师!
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637