输入密码,成功后显示欢迎,输入三次锁定,保存错误
user_name = ‘Hello world‘
password = ‘321321‘
url = ‘D:\7z‘ #似乎没用到
answer1 = input(‘请输入用户名\n‘)
answer2 = input(‘请输入密码\n‘)
if answer1 == user_name and answer2 == password:
print(‘ok,welcome‘)
else :
answer1 = input(‘agqin‘)
answer2 = input(‘again‘)
count = 2
while count >0 :
answer1 = input(‘agqin‘)
answer2 = input(‘again‘)
if answer2 !=password:
count = count -1
with open(‘D:\\7z\\a\\1.txt‘,‘w‘) as f:
f.write(‘count = 0‘,)
f.close()
else:
print(‘good,welcome‘)
变量全部大写字母表示常量,例如π = 3.1415.....
1位=1bit
8bit = 1byte = 1字节
cd../../..返回多层目录