首页 > 编程语言 > 详细

python学习笔记2-tuple

时间:2018-03-27 13:12:36      阅读:203      评论:0      收藏:0      [点我收藏+]

tuple:

#元组也是List,但是值不能变
a=(‘123‘,‘234‘,‘1234‘)
print(a[1])

mysql=(‘127.0.0.1‘,‘3306‘,‘‘root‘,‘123456‘)
print(mysql.count(‘root‘))


#例子
all_user={}
while True:
    username=input(‘username:‘).strip()
    passwd=input(‘passwd:‘).strip()
    cpwd=input(‘cpwd:‘).strip()
    if username and pwd and cpwd:
        if username in all_user:
            print(‘用户名已经存在‘)
        else:
            if pwd==cpwd :
                all_user[username]=passwd
            else:
                print(‘两次密码不一致‘)
    else:
        print(‘账号密码不能空‘)




#登录例子
all_users={}
while True:
    username=input(‘username:‘).strip()
    passwd=input(‘passwd:‘).strip()
    if username and passwd:
       if username in all_users:
           passwd=all_users[username]
           if passwd==all_users[username]:
              print(‘登录成功‘)
              break
           else:
              print(‘密码错误‘)
       else:
          print(‘用户名不存在‘)
    else:
        print(‘用户密码不能为空‘)

 

python学习笔记2-tuple

原文:https://www.cnblogs.com/SuKiWX/p/8656550.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!