python---游戏登录

#!/usr/bin/env python
#coding=utf-8

import os,sys

width = 30
title = '穿越火线'
len_title = len(title)
half = (width - len_title) // 2
i = 0

print '*'*width
print '*'*half+'  '+title+'  '+'*'*half
print '*'*width

while True:
        name = raw_input('Please input your name: ') .strip()
        if name == 'strike':
                print "Welcome, %s!" % name
                for i in range(3):
                        password = raw_input('Please input your password:')
                        p = '123'
                        if password !=p:
                                print "Wrong password!"
                                continue
                                i += 1
                        else:
                                print "%s" %title
                                break
                else:
                        print 'Three times over, program will exiting!'
                        break
        else:
                print "%s is not exist." % name
                YN = raw_input('Do you want to sign your owner name,input Y/N: ')
                if YN == 'Y':
                        print "Signing..."
                        os.system('sleep 2')
                        continue
                if YN == 'N':
                        print "Program exiting...!"
                        break


本文出自 “经验来自痛苦” 博客,谢绝转载!

你可能感兴趣的:(python)