上传文件至 /
This commit is contained in:
13
text1.py
Normal file
13
text1.py
Normal file
@@ -0,0 +1,13 @@
|
||||
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')
|
||||
Reference in New Issue
Block a user