2012-03-05 30 views
1

我剛剛從python 2切換到python 3.我用python 2編寫的一個python代碼失敗了。該錯誤不能理解,我不想將我的Python 2代碼轉換爲Python 3兼容版本。如果我重寫整個程序會更好。在python 3中需要遠程登錄模塊的教程0

但是,在谷歌的資源是混亂的,所以我無法找到任何資源的python 3 telnetlib模塊。有沒有人知道任何資源?

我連接錯誤消息時我執行中途轉換Python代碼:

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 
+0

如果你不想將程序轉換爲Python,那麼不要使用PYTHON 3運行它。我的意思是認真的?如果你不想讓它與Python 3兼容,你認爲用Python 3運行它是否合理? – 2012-03-05 07:44:08

回答

1

如果你的程序已經在Python 2.x的工作,那麼我認爲你真正需要的是採取看文檔中的Text Vs. Data Instead Of Unicode Vs. 8-bit節,因爲它解釋了爲什麼你要回溯的問題:

與2.x的情況最大的不同是,任何企圖在Python配上文字和數據3.0加薪TypeError