如何在 tn.read_until() 中包含正则表达式?

How to include regular expression in tn.read_until()?

import telnetlib
tn = telnetlib.Telnet(IP)
tn.read_until("abcd login: ") --> This is only to match a particular pattern

可以在 tn.read_until() 中包含通用模式吗? 例如:提示可以是 "xyz login: " , "abcd login: "

在正则表达式中,我们使用 re.match('(.*)login: ',prompt) 。但我不这么认为,这在 tn.read_until() 中有效,因为它期望的参数本身就是一种模式。有什么办法可以处理吗?

Telnet.expect 接受正则表达式列表:

tn.expect([r"\w+ login: "])