# 随机生成双色球import random# 随机数 1-16之间# r = random.randint(1,16)# print(r)phone_numbers_str = "匪警[110],火警[119],急救中心[120],道路交通事故报警[122],水上求救专用电话[12395],天气预报[12121],报时服务[12117],森林火警[12119],电力服务[95598],红十字会急救台[999],公安短信报警[12110],通用紧急求救[112],信产部IP/网站备案[010-66411166]"weather_str="北京,2019年1月12日,多云,8°C,-4°C,南风3级~上海,2019年1月12日,小雨,9°C,6°C,北风2级~广州,2019年1月12日,阵雨转多云,22°C,15°C,持续无风向微风" # 生成双色球def generate_unionlotto(number): for j in range(0, number): if j <= number: for i in range(0, 6): red = random.randint(1, 33) print(red, end=" ") blue = random.randint(1, 16) print(blue) j += 1 # 号码百事通def find_phone(keyword): phone_list = phone_numbers_str.split(",") # print(phone_list) for p in phone_list: if p.find(keyword) != -1: print(p) else: print(‘查询失败...‘) break # 查询天气def get_weather(city): city_list = weather_str.split(‘~‘) # print(city_list) weather_data = {} for i in range(0, len(city_list)): w = city_list[i].split(",") weather = { ‘name‘: w[0], ‘date‘: w[1], ‘weather‘: w[2], ‘max‘: w[3], ‘min‘: w[3], ‘wind‘: w[5] } weather_data[weather[‘name‘]] = weather if city in weather_data: print( weather_data[city]) else: print(‘查询失败...‘) while(True): print(‘0-结束程序‘) print(‘1-双色球随机选号‘) print(‘2-号码百事通‘) print(‘3-明日天气预测‘) c = input(‘请输入功能编号:‘) if c == ‘1‘: n = int(input(‘请输入要生成的双色球号码次数: ‘)) generate_unionlotto(n) elif c == ‘2‘: n = input(‘请输入您要查询的机构或者电话号码: ‘) find_phone(n) elif c== ‘3‘: n = input(‘请输入您要查询的天气: ‘) get_weather(n) elif c == "0": break else: print(‘编号输入错误...‘) print(‘==============================‘)print(‘感谢您的使用,再见...‘)
原文地址:https://www.cnblogs.com/ericblog1992/p/11275882.html
时间: 2024-10-03 21:48:25