Python Simple interactive operation, instance
Method One:
#!/usr/bin/env python
#encoding: UTF8
# Filename:interactive.py
Name= raw_input ("Please input your name:")
passwd= raw_input ("Please input your passwd:")
Count = 0
temp = 0
If name = = ' Liu ':
if passwd = = ' 123 ':
print ' Welcome login! '
Else
For I in range (4):
Count + = I
if passwd = = ' 123 ':
print ' Welcome login '
Break
if (count = = 3):
Print "You passwd locked!"
Else
passwd= raw_input ("Please reset input your passwd:")
elif passwd = = ' 123 ':
print ' true ', passwd
For x in range (4):
Temp + = X
print ' Varlue: ', temp
If name = = ' Liu ':
print ' Welcome login '
Break
if (temp = = 3):
Print "You name locked"
Break
Else
Name= Str (raw_input ("Please reset input your name:"))
Else
print ' name,passwd error!: '
#####################################################################################
Method Two:
#!/usr/bin/python
# Filename:interactive_1.py
i = 1
While 1:
Name = Raw_input ("Please input your name:")
email = raw_input ("Please input your email:")
QQ = Int (raw_input ("Please input your QQ:"))
S2 = "{NAME:[EMAIL,QQ]}"
S3 = eval (S2)
# if S3.has_key (Name):
S3 = Dict (S3.items () + s3.items ())
Print I
i + = 1
If I > 3:
Break
#s3 (S3.items ()) + = S3 (S3.items ())
# Else:
# raw_input ("First please input your information! Enter ")
Python Example 1