PyWxDump/test2.py

28 lines
10 KiB
Python
Raw 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
def raw_to_escaped(raw_str):
def replace_match(match):
escape_seq = match.group(1)
# 常见转义字符映射
escape_map = {
r'\n': '\n',
r'\t': '\t',
r'\r': '\r',
r'\\': '\\',
r'\"': '"',
r'\'': "'",
}
return escape_map.get(escape_seq, escape_seq) # 如果不是特殊字符,原样返回
# 正则匹配 \ + 特定字符(如 \n, \t 等)
return re.sub(r'\\([nrt\\"\'])', replace_match, raw_str)
# 示例
json_data = r"\n{\n \"header\": {\n \"title\": \"AI技术交流群报告\",\n \"date\": \"2025-04-29\",\n \"metaInfo\": {\n \"totalMessages\": \"35\",\n \"activeUsers\": \"12\",\n \"timeRange\": \"07:03 - 15:36\"\n }\n },\n \"sections\": {\n \"hotTopics\": {\n \"items\": [\n {\n \"name\": \"AI开发工具讨论\",\n \"category\": \"技术交流\",\n \"summary\": \"群成员讨论了AI开发工具的使用体验包括AI生成的小程序bug问题、源码购买和微调限制等话题。\",\n \"keywords\": [\"AI小程序\", \"源码购买\", \"微调限制\"],\n \"mentions\": \"6\"\n },\n {\n \"name\": \"熬夜与工作效率\",\n \"category\": \"工作生活\",\n \"summary\": \"群成员围绕熬夜工作、工作效率和健康问题展开了讨论,分享了各自的熬夜经历和看法。\",\n \"keywords\": [\"熬夜\", \"工作效率\", \"健康\"],\n \"mentions\": \"8\"\n }\n ]\n },\n \"tutorials\": {\n \"items\": [\n {\n \"type\": \"NEWS\",\n \"title\": \"Qwen3深夜正式开源\",\n \"sharedBy\": \"苍何\",\n \"time\": \"2025-04-29 09:20:23\",\n \"summary\": \"Qwen3小尺寸模型开源性能优异。\",\n \"keyPoints\": [\"开源\", \"小尺寸\", \"高性能\"],\n \"url\": \"http://mp.weixin.qq.com/s?__biz=MzIyMzA5NjEyMA==&mid=2647670717&idx=1&sn=edec1f6cda0c1227e72cd07abf4228ff&chksm=f19a699bb993eb9ed2850ba329f382668bc7edc8a2d7d4a94de2d29c15cf87aa05bf6b48dc6d&mpshare=1&scene=1&srcid=0429TzXAJtS5jA2QI9hLEroV&sharer_shareinfo=7fd7493f3ccf9923f55b48a05619ce1b&sharer_shareinfo_first=fc872ba73c219b858d700a9db530b5b1#rd\",\n \"domain\": \"mp.weixin.qq.com\",\n \"category\": \"AI技术\"\n },\n {\n \"type\": \"TUTORIAL\",\n \"title\": \"体验完刚上线的Vidu Q1\",\n \"sharedBy\": \"苍何\",\n \"time\": \"2025-04-29 09:39:42\",\n \"summary\": \"Vidu Q1 AI视频创作体验分享包含教程。\",\n \"keyPoints\": [\"AI视频\", \"创作教程\", \"清晰度提升\"],\n \"url\": \"http://mp.weixin.qq.com/s?__biz=MzU4NTE1Mjg4MA==&mid=2247493267&idx=1&sn=0189fb501578ce8e27142fbe2f590d03&chksm=fc9a946728c367005c19cb5a335300d05d51a441f9f20424a0a72c904a47bdf003252576318a&mpshare=1&scene=1&srcid=04297l70B2zsuypDfjUh0rh5&sharer_shareinfo=181efb947f938ab90786c776bf7bbda7&sharer_shareinfo_first=181efb947f938ab90786c776bf7bbda7#rd\",\n \"domain\": \"mp.weixin.qq.com\",\n \"category\": \"AI视频\"\n }\n ]\n },\n \"importantMessages\": {\n \"items\": [\n {\n \"time\": \"2025-04-29 10:00:18\",\n \"sender\": \"苍何\",\n \"type\": \"NEWS\",\n \"priority\": \"\",\n \"content\": \"2025年04月29日 AI科技早报\",\n \"fullContent\": \"2025年04月29日 AI科技早报\\n\\n1、阿里开源8款Qwen3模型集成MCP性能超DeepSeek-R1、OpenAI o1。\\n\\n2、Qafind Labs发布ChatDLM扩散语言模型推理速度高达2800 tokens/s。\\n\\n3、腾讯开源Kuikly跨端框架基于Kotlin支持多平台开发已应用于QQ。\\n\\n4、OpenAI 推出 ChatGPT 购物功能,用户可通过 ChatGPT 便捷购物。\\n\\n5、字节Seed团队提出PHD-Transformer突破预训练长度扩展瓶颈。\\n\\n6、百度发布文心快码3.5版本与多模态AI智能体Zulu助力工程师提效。\\n\\n7、Kimi与财新传媒合作提供专业财经内容推动AI+传统媒体融合。\\n\\n8、苹果加速「N50」智能眼镜项目融合AI技术预计2027年亮相。\\n\\n9、研究显示OpenAI o3在病毒学领域超越94%人类专家,生物安全引关注。\\n\\n10、华为测试自研AI芯片Ascend 910D旨在替代英伟达H100芯片。\\n\\n11、🔥【记得收藏】早报同步更新到开源 AI 知识库https://u55dyuejxc.feishu.cn/wiki/FkmNwxYHDigJ3akIUGHc8MSTn4d\"\n }\n ]\n },\n \"dialogues\": {\n \"items\": [\n {\n \"type\": \"DIALOGUE\",\n \"messages\": [\n {\n \"speaker\": \"好名字\",\n \"time\": \"2025-04-29 08:16:23\",\n \"content\": \"这个我弄完ai做的小程序有bug流程走不通还改不了[捂脸]\"\n },\n {\n \"speaker\": \"贾👦🏻\",\n \"time\": \"2025-04-29 08:54:33\",\n \"content\": \"可以微调 不过源码需要买的\"\n },\n {\n \"speaker\": \"好名字\",\n \"time\": \"2025-04-29 09:13:32\",\n \"content\": \"微调一次,然后再想调就需要开会员了\"\n },\n {\n \"speaker\": \"贾👦🏻\",\n \"time\": \"2025-04-29 09:14:09\",\n \"content\": \"需求变更一个字 就需要重新购买[破涕为笑]\"\n }\n ],\n \"highlight\": \"需求变更一个字 就需要重新购买\",\n \"relatedTopic\": \"AI开发工具限制\"\n }\n ]\n },\n \"qa\": {\n \"items\": [\n {\n \"question\": {\n \"asker\": \"银色子弹-捷\",\n \"time\": \"2025-04-29 11:10:26\",\n \"content\": \"问一下win11电脑你长时间没清理运行慢一般用什么来清理电脑 不要360啊那个太流氓了想知道各位大佬有没有优秀的软件推荐一下\",\n \"tags\": [\"电脑清理\", \"软件推荐\"]\n },\n \"answers\": [\n {\n \"responder\": \"昏沉沉的\",\n \"time\": \"2025-04-29 11:11:59\",\n \"content\": \"ccclean\",\n \"isAccepted\": false\n },\n {\n \"responder\": \"🤑程序儒\",\n \"time\": \"2025-04-29 11:13:07\",\n \"content\": \"360极速版、Wise Care 365\",\n \"isAccepted\": false\n },\n {\n \"responder\": \"AHapi²⁰²⁵\",\n \"time\": \"2025-04-29 11:13:38\",\n \"content\": \"仅2MBWindows瞬间超级丝滑\\n这才是真神器\\n\\n<a href=\\\"https://mp.weixin.qq.com/s/es77Jc6Du03ppJD5XJeQUg\\\" target=\\\"_blank\\\">点击查看详情</a>\",\n \"isAccepted\": true\n }\n ]\n }\n ]\n },\n \"analytics\": {\n \"heatmap\": [\n {\n \"topic\": \"AI技术\",\n \"percentage\": \"45%\",\n \"color\": \"#3da9fc\",\n \"count\": \"16\"\n },\n {\n \"topic\": \"工作生活\",\n \"percentage\": \"30%\",\n \"color\": \"#4361ee\",\n \"count\": \"10\"\n },\n {\n \"topic\": \"工具推荐\",\n \"percentage\": \"15%\",\n \"color\": \"#00b4d8\",\n \"count\": \"5\"\n },\n {\n \"topic\": \"其他\",\n \"percentage\": \"10%\",\n \"color\": \"#7209b7\",\n \"count\": \"4\"\n }\n ],\n \"chattyRanking\": [\n {\n \"rank\": 1,\n \"name\": \"苍何\",\n \"count\": \"7\",\n \"characteristics\": [\"技术分享\", \"新闻发布\"],\n \"commonWords\": [\"AI\", \"开源\", \"熬夜\"]\n },\n {\n \"rank\": 2,\n \"name\": \"AHapi²⁰²⁵\",\n \"count\": \"6\",\n \"characteristics\": [\"幽默评论\", \"工具推荐\"],\n \"commonWords\": [\"[旺柴]\", \"加班\", \"\"]\n },\n {\n \"rank\": 3,\n \"name\": \"贾👦🏻\",\n \"count\": \"3\",\n \"characteristics\": [\"技术解答\", \"邀请码分享\"],\n \"commonWords\": [\"源码\", \"购买\", \"邀请\"]\n }\n ],\n \"nightOwl\": {\n \"name\": \"苍何\",\n \"title\": \"熬夜冠军\",\n \"latestTime\": \"2025-04-29 09:42:54\",\n \"messageCount\": \"7\",\n \"lastMessage\": \"我熬夜写了这一篇[旺柴]\"\n }\n },\n \"wordCloud\": {\n \"words\": [\n {\n \"text\": \"AI\",\n \"size\": 42,\n \"color\": \"#3da9fc\",\n \"rotation\": 0\n },\n {\n \"text\": \"熬夜\",\n \"size\": 38,\n \"color\": \"#4361ee\",\n \"rotation\": -15\n },\n {\n \"text\": \"开源\",\n \"size\": 36,\n \"color\": \"#00b4d8\",\n \"rotation\": 15\n },\n {\n \"text\": \"小程序\",\n \"size\": 32,\n \"color\": \"#7209b7\",\n \"rotation\": -10\n },\n {\n \"text\": \"清理\",\n \"size\": 28,\n \"color\": \"#f72585\",\n \"rotation\": 10\n }\n ],\n \"legend\": [\n {\"color\": \"#3da9fc\", \"label\": \"技术 相关词汇\"},\n {\"color\": \"#4361ee\", \"label\": \"生活 相关词汇\"},\n {\"color\": \"#00b4d8\", \"label\": \"工具 相关词汇\"}\n ]\n }\n },\n \"footer\": {\n \"dataSource\": \"AI技术交流群聊天记录\",\n \"generationTime\": \"2025-04-29 16:00:00\",\n \"statisticalPeriod\": \"2025-04-29 07:03 - 15:36\",\n \"disclaimer\": \"本报告内容基于群聊公开讨论,如有不当内容或侵权问题请联系管理员处理。\"\n }\n}\n"
print(json_data)