码迷,mamicode.com
首页 > 编程语言 > 详细

Python练习程序(一)Python用户交互和流程控制

时间:2015-12-02 18:39:13      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:python

功能:用户认证后,联系人信息查询

#!/usr/bin/env python
#coding=utf-8
name = raw_input("请输入你的用户名:")
while name != ‘fgf‘:
        name = raw_input("没有查询到此用户。\n请重新输入你的用户名:")
else:
        password = raw_input("请输入你的密码:")
        p = ‘123‘
        while password != p:
                password = raw_input("错误密码,请重新输入:")
        else:
                print ‘欢迎进入查询系统。(输:q退出)‘
                while True:
                        match_yes = 0    #匹配标示
                        input = raw_input("\033[31m请输入你想查询的名字:\033[0m")
                        if input == ":q":break
                        contact_file = file(‘contact_list.txt‘)
                        while True:
                                line = contact_file.readline()
                                if len(line) == 0 or input == ‘‘:break    #避免回车输出所有内容
                                if input in line:
                                        print ‘匹配项: \033[36;1m%s\033[0m‘ % line
                                        match_yes = 1
                        if match_yes == 0 : print ‘没找到匹配项。‘


本文出自 “凌风” 博客,请务必保留此出处http://fgf01.blog.51cto.com/3907069/1718993

Python练习程序(一)Python用户交互和流程控制

标签:python

原文地址:http://fgf01.blog.51cto.com/3907069/1718993

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!