Python 3 telnetlib "bytes-like object is required"
<p>I am new to python and I would like to make a program that sends commands to a 2960 Cisco switch and have it display back the results.</p>

<p>I am able to make a connection to the switch and have it show me my banner message, but once I try to type my username and password, everything goes down hill. Here is the error message I get:</p>

<pre><code>Traceback (most recent call last):
  File "C:/Users/jb335574/Desktop/PythonLearning/Telnet/TelnetTest2.py", line 8, in &lt;module&gt;
    tn.read_until("Username: ")
  File "C:\Users\admin1\AppData\Local\Programs\Python\Python35-32\lib\telnetlib.py", line 302, in read_until
    i = self.cookedq.find(match)
TypeError: a bytes-like object is required, not 'str'
</code></pre>

<p>Here is my code:</p>

<pre><code>import telnetlib

un = "admin1"
pw = "password123"

tn = telnetlib.Telnet("172.16.1.206", "23")
tn.read_until("Username: ")
tn.write("admin1" + '\r\n')
tn.read_until("Password: ")
tn.write("password123" + '\r\n')
tn.write("show interface status" + '\r\n')

whathappened = tn.read_all()
print(whathappened)$
</code></pre>