老师我这个python版本用time.clock()显示报错,要用time.process_time()吗?
老师,不是说加了?就是尽可能少的匹配,而+的匹配次数是1或无限次,那么这个题不就应该选c么,为什么回选a
老师,vssode,我按住鼠标右键,没有可以运行的页面选择,这是为什么呀?
代码
import re import requests url = 'https://www.duitang.com/napi/blog/list/by_search/?kw=陈钰琪&type=feed&include_fields=top_comments,is_root,source_link,item,buyable,root_id,status,like_count,like_id,sender,album,reply_count,favorite_blog_id&_type=&start=24&_=1602406546709' zhao = requests.get(url).content.decode('utf-8') print(zhao) patten = r'https:.jpg|https:.jpeg|https:.png' p = re.findall(patten,zhao) for i in p: print(i)
老师怎么匹配,抓出来了,匹配不上
import re p = 'src=(.+?\.jpg")' s = r'\t\t\t\t\t\t\t\t\t\t\t<img src="https://img.bjsxt.com/uploadfile/2018/04/bj_city.jpg" />\n'
请问老师代码中的
p = 'src=(.+?\.jpg")' 里面的\.是代表匹配.这个符号吗 如果要匹配问号 该怎么写哈
''' 闭包的特殊用途: 1.可以在不休改源码的前提下,增加新的功能 2.日志的功能(统计访问的事件,访问功能,写到日志文件中)权限验证(下载之前,验证当前账户是否是会员) 开闭原则: 开发 添加功能 关闭 修改源代码 ''' #定义一个记录日志的函数;将访问事件以及访问的函数名写入到文件中(log.txt) def writeLog(func): try: file = open('log.text','a', encoding='utf-8') #写入相关数据信息(访问函数名,访问的时间) file.write(func.__name__) file.write('\t') #写入访问的时间 #strTime = time.asctime() file.write(time.asctime()) file.write('\n') except Exception as e: print(e.args) finally: #关闭文件 file.close() def func1(): writeLog(func1) print('我是功能1') def func2(): writeLog(func2) print('我是功能2') func1() func2()
re (parameter):pattern = v = re.match(patternparameter) v: (v) : () __name__ == : s = test(())
运行结果
请输入邮箱地址:stone.zhao@asteelflash.com匹配成功 <re.Match object; span=(0, 24), match='stone.zhao@asteelflash.c'>
class Animal(): def __init__(self,color): self.color=color def eat(self): print("我需要吃饭") def sleep(self): print("我需要睡觉") #使用type动态创建一个类,父类就是animal Dog=type("Dog",(Animal,),{"age":3,"sleep":sleep}) dog=Dog("red") print(dog.age) dog.sleep() print(dog.color) dog.eat()
老师 这个sleep函数 为什么在父类的外面 同样参数self是什么意思 type后边指定一个函数是什么意思
老师,*args是把多个参数包装成一个元组,为什么test3最终是给test2输入了一个元组可以执行,我直接给一个元组就不行?
老师你好:
我有点疑问,感觉是对的,又不敢确定,向老师求证
老师,我记得之前高淇老师讲的是在命令行中是[-5,256]之间的数会被缓存起来;在文件中[-5,任意正整数]都会被缓存起来,是这样吗?是版本的问题吗?
老师打扰一下,课程中提到的两个参数是哪两个参数,我只看到一个参数(test1)另一个是哪个?
关于3楼提的问题。表示我在听老师讲闭包时也没有说内部函数必须返回外部函数。老师只说了必须有如下3个条件:1、嵌套函数定义(一般为两层);
2、内部函数使用外部函数定义的变量;
3、外部函数一定要有返回值,且是返回内部函数名。
麻烦老师核实一下这个问题,谢谢~
import re def test(parameter): pattern = r'[a-zA-Z1-9.]{4,19}@[a-zA-Z0-9]{2,18}.[com$|net$]' v = re.match(pattern, parameter) if v: print("匹配成功",v) #print(v) else: print("请输入正确的邮箱") if __name__ == '__main__': s = test(input("请输入邮箱地址:"))
请输入邮箱地址:stone.zhao@asteelfalsh.com匹配成功 <re.Match object; span=(0, 24), match='stone.zhao@asteelfalsh.c'>
老师看看为什么不能全部输出
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2024 百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637