From 1919272ca1880e57af1df96e5490b05d65df367a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=89=BF=E6=81=A9?= <2509165040@student.example.com> Date: Thu, 2 Apr 2026 16:06:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- movie.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 movie.py diff --git a/movie.py b/movie.py new file mode 100644 index 0000000..bdb3a45 --- /dev/null +++ b/movie.py @@ -0,0 +1,29 @@ +import re +html = """ +
+

《流浪地球》

+(2024) +8.5 +导演: 郭帆 +
+
+

《你好,李焕英》

+(2021) +7.9 +导演: 贾玲 +
+""" + +name_pattern = r'

《([^》]+)》

' +year_pattern = r'\((\d+)\)' +rating_pattern = r'([\d.]+)' +director_pattern = r'导演: ([^<]+)' + +names = re.findall(name_pattern, html) +years = re.findall(year_pattern, html) +ratings = re.findall(rating_pattern, html) +directors = re.findall(director_pattern, html) + +for +name, year, rating, director in zip(names, years, ratings, directors): + print(f"{name} {year} {rating} {director}") \ No newline at end of file