0
當運行在終端以下代碼:NameError:名稱「___」沒有定義
import getpass
import sys
import telnetlib
import time
user = input("Please Enter Your Username: ")
password = input("Please Enter Your Password: ")
ip = input("Please Enter RPi IP Address: ")
bot = telnetlib.Telnet(ip)
bot.read_until("login: ")
bot.write(user + "\n")
bot.read_until("password: ")
bot.write(password + "\n")
我得到一個錯誤消息說:
Traceback (most recent call last):
File "con.py", line 6, in <module>
use = input("Please Enter Your Username: ")
File "<string>", line 1, in <module>
NameError: name 'pi' is not defined
PS pi
是什麼送給可變user
。它運行在python shell中(直到它到達telnet部分,但它顯然不能在shell中工作)。爲什麼它不會在終端中運行?
由於
'input'應該是'raw_input'。 – Blender
@blender不適用於Python 3及以上版本? – crossboy007
它看起來不像你在用Python 3執行腳本。你是如何運行它的? – Blender