python如何输入一个字典_Python怎么通过字典的键和值做一个登录程序?

展开全部

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()

科科。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值