zoukankan      html  css  js  c++  java
  • 生日检索

    》题目要求

      》》用户输入一个姓名

      》》打印出这个姓名对应的人的生日

    》程序实现

     1 birthday = {"王江智":"1996/12/26",
     2             "杨顺裙":"1996/09/04",
     3             "王杨梅":"1990/10/15",
     4             "王杨灿":"1992/02/04",
     5             "王杨帅":"1993/10/03",
     6             "杨玉林":"2013/10/13"}
     7 
     8 while True:
     9     name = input("Please input the name of one person whose birthday you want to know:")
    10     if name == "":
    11         break
    12     if name in birthday:
    13         print("The birthday of "+name + " is "+birthday[name])
    14     else:
    15         print("There is no birthday infomation of "+name)
    View Code

    》改进方案1

      如果输入的姓名没有对应的生日,提醒用户是否要录入生日;

      如果用户同意录入生日,那么用户下次再输入这个姓名是就会返回一个生日

      三少想吃火锅啦,待更新......   2017年1月8日10:17:33 更新

     1 import sys
     2 birthdays = {
     3     "王杨1": "2990/10/15",
     4     "王杨2": "1992/02/04",
     5     "王杨4": "1993/10/03",
     6     "杨3": "2013/10/13",
     7     "杨5": "1993/11/05"
     8 }
     9 while True:
    10     name = input("请输入姓名(exit表示退出):")
    11     if "exit" == name:
    12         sys.exit()
    13 
    14     if name in birthdays:
    15         print("The birthday of " + name + " is " + birthdays[name])
    16     else:
    17         print("There is no information about " + name)
    18         choose = input("Do you want to input the information of birthday about " + name + ":")
    19         if ("y" == choose) or ("Y" == choose):
    20             date = input("Please input some information about " + name + ":")
    21             birthdays[name] = date
    22         print("The database of birthdays has upgraded.")
    23         print(birthdays)
    改进程序1

    》改进方案2

      新录入的数据没能存储下来,待更新中......

  • 相关阅读:
    Javascript的ajax
    关于跨模块拿取数据的思路AJAX实现
    JAVA的整型与字符串相互转换
    接口返回数据和数组
    接口返回数据是一条数据和一个数组的区别
    最初的代码
    http发送请求方式;分为post和get两种方式
    Java学习---- 数组的引用传递
    Java学习--数组与方法
    Java学习--数组的定义和使用
  • 原文地址:https://www.cnblogs.com/NeverCtrl-C/p/6128828.html
Copyright © 2011-2022 走看看