Python—什么是“Python”&引用;意思是
我正在使用Python,并正在考虑如何编写一个请求UN和密码的程序。我正在使用“while循环”教程 对于命令和Input1与Input2,为什么它们将变量显示为相等“” 它们表明:Python—什么是“Python”&引用;意思是,python,login,passwords,Python,Login,Passwords,我正在使用Python,并正在考虑如何编写一个请求UN和密码的程序。我正在使用“while循环”教程 对于命令和Input1与Input2,为什么它们将变量显示为相等“” 它们表明: name = raw_input("What is your UserName: ") password = raw_input("What is your Password: ") print "To lock your computer type lock." command = "" input1
name = raw_input("What is your UserName: ")
password = raw_input("What is your Password: ")
print "To lock your computer type lock."
command = ""
input1 = ""
input2 = ""
while command != "lock":
command = raw_input("What is your command: ")
while input1 != name:
input1 = raw_input("What is your username: ")
 这只是意味着它们声明了两个字符串
input1
和input2
,并在接受用户输入之前确保它们是空字符串。使用command=“”
将创建一个名为command的空字符串变量。这是经常使用的,因此您可以清除变量并再次使用它
例如:
>>> command = "hello world"
>>> print command
hello world
>>> command = ""
>>> print command
>>>
他们在使用变量之前定义变量,否则会出现一个错误,即命令未定义,程序将失败。这也类似于JavaScript中的
var input1;var输入2代码>