#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @File : passwd.py
# @Author: wmy
# @Date : 2018/1/13
import getpass
_username = 'wmy'
_password = 'cwfx2009'
#
#
# print(username, password)
# python 需要强制缩进, 表示关系
count = 0
while count < 6:
print('please input login information')
print('you have {0} times'.format(6 - count))
username = input("username:")
password = input("password:")
if username == _username and password == _password:
print('welcome user {name} login'.format(name=username))
break
else:
print('invalid user')
count += 1
else:
print('you have no chance to login ')
本文比较重要得是 ,python 的格式比较严格,该缩进就缩进,对于循环不需要用大括号来进行 编译标志