Files
2026-04-02 16:07:32 +08:00

13 lines
395 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import re
text = '''
2024-03-15 天气:晴 温度15-25°C
2024-03-16 天气:多云 温度12-20°C
2024-03-17 天气:小雨 温度10-18°C
'''
pattern = r'(\d{4}-\d{2}-\d{2})\s*天气:([^ ]+)\s*温度:(\d+)-(\d+)°C'
matches = re.findall(pattern, text)
for match in matches:
date, weather, low, high = match
print(f'{date}: {weather}, {low}°C-{high}°C')