获得的命令输出字符串如下.
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"}所需输出:我希望Python代码提取如下列表
{'Handle: 0xFF00', Handle: 0xC00A', Handle: 0xDD00}发布于 2022-05-30 20:00:20
下面的代码列出了所需的输出。
import re
key = 'Handle: 0x[0-9a-fA-F]+'
final_list = []
final_list = re.findall(key, str(input_string))
print(final_list)https://stackoverflow.com/questions/72437498
复制相似问题