Home > other >  Python dictionary special key how to obtain keys
Python dictionary special key how to obtain keys

Time:11-27

{TopicPartition(topic=u'test', partition=0): [ConsumerRecord(topic=u'test', partition=0, offset=33, timestamp=1606331343841, timestamp_type=0, key=None, value='https://bbs.csdn.net/topics/{"status": "1", "priority": "4", "alarmContent": "\\u6807\\u8bc6AHCI.Embedded.2-1\\uff0c\\u540d\\u79f0C620 Series Chipset Family SATA Controller [AHCI mode]\\u7684\\u5b58\\u50a8\\u63a7\\u5236\\u5361\\u5065\\u5eb7\\u72b6\\u6001\\u5f02\\u5e38", "resourceName": "\\u6807\\u8bc6AHCI.Embedded.2-1\\uff0c\\u540d\\u79f0C620 Series Chipset Family SATA Controller [AHCI mode]\\u7684\\u5b58\\u50a8\\u63a7\\u5236\\u5361\\u5065\\u5eb7\\u72b6\\u6001\\u5f02\\u5e38", "alarmTime": 1595404863000, "alarmId": "567"}', checksum=441488333, serialized_key_size=-1, serialized_value_size=464)]}

Taking out the value of the value

CodePudding user response:

The above a lot of you looks like a dictionary, and like a string, but is not, what is?

CodePudding user response:

 import re 
str='''{TopicPartition(topic=u'test', partition=0): [ConsumerRecord(topic=u'test', partition=0, offset=33, timestamp=1606331343841, timestamp_type=0, key=None, value='https://bbs.csdn.net/topics/{"status": "1", "priority": "4", "alarmContent": "\\u6807\\u8bc6AHCI.Embedded.2-1\\uff0c\\u540d\\u79f0C620 Series Chipset Family SATA Controller [AHCI mode]\\u7684\\u5b58\\u50a8\\u63a7\\u5236\\u5361\\u5065\\u5eb7\\u72b6\\u6001\\u5f02\\u5e38", "resourceName": "\\u6807\\u8bc6AHCI.Embedded.2-1\\uff0c\\u540d\\u79f0C620 Series Chipset Family SATA Controller [AHCI mode]\\u7684\\u5b58\\u50a8\\u63a7\\u5236\\u5361\\u5065\\u5eb7\\u72b6\\u6001\\u5f02\\u5e38", "alarmTime": 1595404863000, "alarmId": "567"}', checksum=441488333, serialized_key_size=-1, serialized_value_size=464)]}'''
Print (re. Search (r '(? <=value=https://bbs.csdn.net/'). *? (?=\ '), STR) group ())

"" "the OUTPUT:
{" status ":" 1 ", "priority" : "4", "alarmContent" : "\ u6807 \ u8bc6AHCI. Embedded. 2-1 \ uff0c \ u540d \ u79f0C620 Series Chipset Family SATA Controller \ [AHCI mode] u7684 \ u5b58 \ u50a8 \ u63a7 \ u5236 \ u5361 \ u5065 \ u5eb7 \ u72b6 \ u6001 \ u5f02 \ u5e38", "resourceName" : "\ u6807 \ u8bc6AHCI. Embedded. 2-1 \ uff0c \ u540d \ u79f0C620 Series Chipset Family SATA Controller \ [AHCI mode] u7684 \ u5b58 \ u50a8 \ u63a7 \ u5236 \ u5361 \ u5065 \ u5eb7 \ u72b6 \ u6001 \ u5f02 \ u5e38", "alarmTime:" 1595404863000, "alarmId" : "567"}
"" "
  • Related