1

I just switched from python 2 to python 3. One of my python code written with python 2 failed. The error cannot be understand and I don't want to convert my python 2 code into python 3 compatible version. It would be better if I just rewrite the whole program.

However, the resource in google is confusing so I can't find any resource for python 3 telnetlib module. Does anyone know any resource for that?

I attached the error message when I executed the half-way converted python code:

File "E:\Python_Program\telnet.py", line 122, in <module>
    tn.write(ftpUsername + "\n")
  File "C:\Python32\lib\telnetlib.py", line 277, in write
    if IAC in buffer:
TypeError: 'in <string>' requires string as left operand, not bytes
lamwaiman1988
  • 3,729
  • 15
  • 55
  • 87
  • If you don't want to convert the program to Python THEN DON'T RUN IT WITH PYTHON 3. I mean seriously? Do you think it makes sense to run it with Python 3 if you son't want it to work with Python 3? – Lennart Regebro Mar 05 '12 at 07:44

1 Answers1

1

If your program is already working in python 2.x, then I think that what you really need is take a look at the Text Vs. Data Instead Of Unicode Vs. 8-bit section in the documentation since it explains why you're getting the traceback in the question:

The biggest difference with the 2.x situation is that any attempt to mix text and data in Python 3.0 raises TypeError

jcollado
  • 39,419
  • 8
  • 102
  • 133