Python程序设计任务驱动式教程_9.2提取排名Top25的电影详细参数 re模块及其主要功能函数.pptxVIP

  • 7
  • 0
  • 约1.73千字
  • 约 12页
  • 2026-04-28 发布于广东
  • 举报

Python程序设计任务驱动式教程_9.2提取排名Top25的电影详细参数 re模块及其主要功能函数.pptx

内容提要;提取排名Top25的电影详细参数——re模块及其主要功能函数;代码实现:

importrequests

importre

importprettytableaspd

importcsv

#评分排行榜的网址

url=/top250?

headers={User-Agent:Mozilla/5.0(Linux;Android6.0;Nexus5Build/MRA58N)AppleWebKit/537.36(KHTML,likeGecko)Chrome/MobileSafari/537.36}

response=requests.get(url,headers=headers)

result=response.text

p=pile(rli.*?spanclass=title(?Pname.*?)/span.*?br(?Pyear.*?)nbsp;‘r.*?spanclass=rating_num

property=v:average(?Pscore.*?)/spanr.*?span(?Pnum.*?)/span,re.S);1.compile()函数

功能:编译正则表达式。

语法格式:compile(source,filename,mode);2.match()函数

功能:从字符串

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档