|
@@ -26,14 +26,19 @@ if __name__ == '__main__':
|
|
|
# print(custom_uuid, num, bucket.name)
|
|
|
|
|
|
# message = """{"seg_id": 2, "cn": {"st": {"rt": [{"ws": [{"cw": [{"sc": 0.00, "w": "停水", "wp": "n", "rl": "0", "wb": 9, "wc": 0.00, "we": 64}], "wb": 9,"we": 64},{"cw": [{"sc": 0.00, "w": "咨询", "wp": "n", "rl": "0", "wb": 65, "wc": 0.00, "we": 132}], "wb": 65,"we": 132}]}], "bg": "9510", "type": "0", "ed": "10950"}}, "ls": false}"""
|
|
|
- message = '{"action":"result","code":"0","data":"{\"seg_id\":0,\"cn\":{\"st\":{\"rt\":[{\"ws\":[{\"cw\":[{\"sc\":0.00,\"w\":\"蜓\",\"wp\":\"n\",\"rl\":\"0\",\"wb\":13,\"wc\":0.00,\"we\":26}],\"wb\":0,\"we\":0}]}],\"bg\":\"9160\",\"type\":\"1\",\"ed\":\"0\"}},\"ls\":false}","desc":"success","sid":"rta108a8500@dx2f5f1b177d38000100"}'
|
|
|
- # 解析最外层 JSON
|
|
|
- message_dict = json.loads(message)
|
|
|
+ # message = '{"action":"result","code":"0","data":"{\"seg_id\":0,\"cn\":{\"st\":{\"rt\":[{\"ws\":[{\"cw\":[{\"sc\":0.00,\"w\":\"蜓\",\"wp\":\"n\",\"rl\":\"0\",\"wb\":13,\"wc\":0.00,\"we\":26}],\"wb\":0,\"we\":0}]}],\"bg\":\"9160\",\"type\":\"1\",\"ed\":\"0\"}},\"ls\":false}","desc":"success","sid":"rta108a8500@dx2f5f1b177d38000100"}'
|
|
|
+ # # 解析最外层 JSON
|
|
|
+ # message_dict = json.loads(message)
|
|
|
+ #
|
|
|
+ # # 解析嵌套的 JSON 字符串
|
|
|
+ # data = json.loads(message_dict['data'])
|
|
|
+ #
|
|
|
+ # # 提取 "w" 字段中的词汇
|
|
|
+ # words = ''.join(cw["w"] for item in data["cn"]["st"]["rt"] for ws in item["ws"] for cw in ws["cw"])
|
|
|
+ #
|
|
|
+ # print(words)
|
|
|
|
|
|
- # 解析嵌套的 JSON 字符串
|
|
|
- data = json.loads(message_dict['data'])
|
|
|
-
|
|
|
- # 提取 "w" 字段中的词汇
|
|
|
- words = ''.join(cw["w"] for item in data["cn"]["st"]["rt"] for ws in item["ws"] for cw in ws["cw"])
|
|
|
-
|
|
|
- print(words)
|
|
|
+ # 读取文件
|
|
|
+ with open('/Users/davidliu/hot_words.txt', 'r', encoding='utf-8') as f:
|
|
|
+ content = f.read()
|
|
|
+ print(content)
|