我有这样一个字符串:
STAT bytes 0
STAT curr_items 0
STAT total_items 0
STAT evictions 0
STAT reclaimed 0
END
我正在尝试获取 curr_items 的值,到目前为止我已经有了
out = telnet.read_until("END")
req = re.search("curr_items", out).group(0).split()[0]
哪个返回 curr_items,如何获取值?
谢谢
请您参考如下方法:
您可以添加 capture group将值与您的正则表达式匹配:
>>> int(re.search("curr_items (\d+)", out).group(1))
0
