import time def dance(): print("跳舞") def sing(): print("唱歌") def log(func): try: f = open(r"log.txt",'a') f.wirte(func.__name__) f.write("\t") f.write(time.asctime()) f.write("\n") except Exception as e : print(e) finally: f.close() def funcOut(func): def funcIn(): log(func) func() return funcIn sing = funcOut(sing) sing() 老师我这个有报错 ,'_io.TextIOWrapper' object has no attribute 'wirte' 唱歌
为什么有这个报错
老师,既然这里变成非贪婪模式,他那为什么不只匹配一个字母T,是不是可以这么理解,后面三个分组都是贪婪的,所有这里贪婪的先拿元素,拿完后就是非贪婪的了
老师,您帮我看下,我这代码里有bug,先输入一次错误的,在输一次正确的以后就不跳出循环,但如果一开始就输入正确的就会跳出循环
import re def e_mail(): s = input('请输入qq邮箱:') pattern = r'[1-9]\d{4,8}@qq.com$' result = re.match(pattern, s) while True: if result: print('验证成功') break else: print('验证失败,请重新输入') e_mail() e_mail()
老师好,请问?在使用上,是不是代表不会超过1次,只会=1或=0
老师re有没有从字符的列表里匹配的方法?
老师,能帮我看下我这有什么问题吗,为什么一运行创建两个文件,对功能1和功能2分别写入
import time def write_log(file_name,func_name): try: file = open(file_name, 'a', encoding='utf-8') useTime = time.ctime() useEvent = func_name connect = useEvent+'\t'+useTime+'\n' file.write(connect) except Exception as e: print(e.args) finally: file.close() def func1(): write_log('log.txt', 'func1') print('我是功能1') def func2(): write_log('log,txt', 'func2') print('我是功能2') func1() func2()
老师,视频中创建sleep函数时为什么要指定self。是因为这个函数是给子类Dog创建的?。不知道self,为什么有会报错
老师,如果这个函数放在类里面应该怎么调用啊?
老师,DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
这个问题咋解决
老师你好,在用闭包添加新功能,不修改原有功能的代码上,有块地方,我不知道理解的有没有错
麻烦您看下,谢谢
import time import sys g1 = (x for x in range(2,10000000,2)) costtime = time.process_time() print("创建生成器耗时:%g"%costtime) print("创建生成器内存开销:%d"%sys.getsizeof(g1))
老师,我这个时间好像有点大,正常吗?,比列表也小不了多少
老师 生成式可以用于遍历多个文件吗? 例如: last1,last2-last5,这种文件。
老师,我有几个地方不明白1.为啥要调用new方法?
2.__new__中,return super() 这个返回父类,的写法是为这么这么写,是格式必须的吗?super(AA, cls)括号中这么写是什么意思?
3. a.v b.v这是为什么这么写?.v是什么?
老师,贪婪模式和非贪婪模式必须是在分组匹配情况下才存在吗?如果正则表达式中没有分组匹配,还存在贪婪模式和非贪婪模式吗?
老师,str1 = re.sub(pattern,replace,s),中,为啥,会把s自动传给replace函数?是re.sub中定义的吗?
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637