我在Python一个完整的新手,但我一直在从事编程的乐趣(自由─)基本距今约1980年另一类型错误:需要对类字节对象,而不是“STR”
使用Python 3.5.2我测试这个脚本:
import time, telnetlib
host = "dxc.ve7cc.net"
port = 23
timeout = 9999
try:
session = telnetlib.Telnet(host, port, timeout)
except socket.timeout:
print ("socket timeout")
else:
session.read_until("login: ")
session.write("on0xxx\n")
output = session.read_some()
while output:
print (output)
time.sleep(0.1) # let the buffer fill up a bit
output = session.read_some()
谁能告诉我,为什么我得到的类型错误:一类字节对象是必需的,而不是“STR”,我该如何解决呢?
可能重复的[TypeError:类似字节的对象是必需的,而不是'str'](http://stackoverflow.com/questions/33003498/typeerror-a-bytes-like-object-is-required-not -str) –