[英]Python code to extract similar key-word with value from a string
String of the command output obtained is as below....得到的命令输出字符串如下......
Key_word = {"Devices on the system.
Device description: device-1
Device status: Healthy
Handle: 0xFF00
Device description: device-2
Device status: Healthy
Handle: 0xC00A
Device description: device-3
Device status: Healthy
Handle: 0xDD00"}
Required Output : I want Python code to extract a list like this所需输出:我希望 Python 代码提取这样的列表
{'Handle: 0xFF00', Handle: 0xC00A', Handle: 0xDD00}
Below code lists the required output.....下面的代码列出了所需的输出.....
import re
key = 'Handle: 0x[0-9a-fA-F]+'
final_list = []
final_list = re.findall(key, str(input_string))
print(final_list)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.