使用分组跟老师敲一样的代码,为什么结果不是None呢
#匹配出网页标签内的数据 <html><title></title></html> # pattern = r'<.+><.+>.+<.+><.+>' #使用这种情况,如果前后不是对称的也是能匹配成功的 pattern = r'<(.+)><(.+)>.+</\2></\1>' # s = '<html><title>我是标签</title></html>' s = "<html><h1>我是标签</header></body>" #如果不用分组这样非网页标签也会被匹配 v = re.match(pattern,s) print(s)
结果如下:
1556937571(1).jpg
collections模块从python3.7版本之后,已经转移到collections.abc中了,现在在从collections中导入Iterable会报错
老师,您好,为什么我的代码在网页中什么也找不到呢?
import re,nltk from urllib.request import urlopen url='https://www.bz6000.cn' html=urlopen(url).read() html=html.decode('utf-8') html[500:5000] #print(html[500:5000]) str = str(html[500:5000]) #print(type(str),type(html[500:5000])) re.findall('.*text.*',str) #print(re.findall('^.+.png$',html[500:5000]))
老师您好,我自己写了如下代码,可是一运行啥也没有,也不打印也没有log文件,请您帮忙看一下有什么问题,谢谢您!
import time def fib(num): list = [] n, a, b = 0, 0, 1 while num > n: list.append(b) a, b = b, a+b n = n + 1 print(list) def function01(): print('我是功能1!') def function02(): print('我是功能2!') def writeLog(func): try: file = open('log.txt', 'a', encoding='utf-8') file.write('文件被打开') file.write('\n') file.write(time.asctime()) file.write('\n') file.write(func.__name__) except Exception as e: print(e.args) finally: file.write('\n') file.write('文件被关闭') file.write('\n') file.close() def outFunct(func): def inFunct(): writeLog(func) func() return inFunct function01 = outFunct(function01)
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637