Python-YCI生活小助理

import random

def Tcolorball(number,n):
    
    for i in range(0,number):
        
        for j in range(0,1):
            
            x = random.randint(1,33)
            
            print(x,end=" ")
            
def Check_number(keyword):
    
    contend ="匪警[110],火警[119],急救中心[120],道路交通事故报警[122],水上求救专用电话[12395],天气预报[12121],报时服务[12117],森林火警[12119],电力服务[95598],红十字会急救台[999],公安短信报警[12110],通用紧急求救[112],信产部IP/网站备案[010-66411166]"
    
    p = contend.split(",")
    
    for q in p:
        
        if q.find(keyword) != -1:
            
            print(q)

            
def Check_city(city):
    
    contend = "北京,2019年1月12日,多云,8°C,-4°C,南风3级~上海,2019年1月12日,小雨,9°C,6°C,北风2级~广州,2019年1月12日,阵雨转多云,22°C,15°C,持续无风向微风"
    
    contend_devide = contend.split("~")
    
    weather_date = {}
    
    for i in range(0, len(contend_devide)):
        
        w = contend_devide[i].split(",")
    
        weather = {"name" : w[0] , "date" : w[1] , "weather": w[2] , "high" : w[3] , "low" : w[4] }
        
        #大字典里由城市命名
       
        weather_date[weather["name"]] = weather
    
    if city in weather_date:

        x = weather_date.get(city)

        print(x)

    else:

        print("")
        

while(True):
    
    print("功能1:随机生成数")
    
    print("功能2:号码百事通")
    
    print("功能1:天气预报")
    
    x = input("请选择功能")
    
    if x == "1":
          
            Tcolorball(5, 5)
            
            break
            
    elif x == "2":
            
            keyword = input("请输入想要查找的机构或号码")
            
            Check_number(keyword)
            
            break
        
    elif x == "3":
           
            city = input("请输入想要查询的城市")
            
            Check_city(city)
        
    else :
            
            print("输出错误,请重新输入")

print("欢迎你重新使用")
       
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值