新闻标题 将空格替换为_ 这样子方便微信中直接点击搜索

This commit is contained in:
liuwei
2025-02-20 09:19:38 +08:00
parent 8a39f1fd2a
commit 70b704b16f

View File

@@ -101,7 +101,7 @@ class News(object):
str = post['data']['cards'][0]['content']
# 遍历列表并格式化每个字典的title, url然后添加到output字符串中
for index, article in enumerate(str, start=1):
title = article['word']
title = article['word'].replace(" ", "_")
# url = article['url']
# 使用f-string格式化字符串并添加到output中
output += f"{index} :#{title}\n"