展开全部
LZ,登陆功能有两个子功能:注册与登陆,,初学版如下:dic = {}
a = raw_input("Please input your name...")
b = raw_input("Please input your passcode...")
dic[a] = b
print a,dic[a]
print '*******'
c = raw_input("Please input your name...")
if c == a:
d = raw_input("Please input your passcode...")
if d == dic[a]:
print'Welcome back %s '%c,'and your passcode is %s',dic[a]
print 'End ...'
函数版如下:#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
dic = {}
def login(name,passcode):
dic['name'] = name
dic['passcode'] = passcode
def register():
while True:
62616964757a686964616fe58685e5aeb931333363376562n = raw_input("Please input your name...")
if n == dic['name']:
p = raw_input("Please input your passcode...")
if p == dic['passcode'] :
print'Welcome back %s '%dic['name'],'and your passcode is %s',dic['passcode']
print 'End ...'
break
else:
print'Your passcode is not correct,try again...'
continue
else:
print"You don't have an account,please register..."
break
a = raw_input("Please input your name...")
b = raw_input("Please input your passcode...")
login(a ,b)
print '**'
register()
科科。。