encode(编码),可以将str类型编码为bytes。 decode(译码),可以将bytes类型转换为str类型。
因此在telnetlib交互的时候需要使用encode()。
tn.read_until("username:".encode())
python3 TypeError: a bytes-like object is required
原文:http://blog.51cto.com/juispan/2090259