import random
defTcolorball(number,n):for i inrange(0,number):for j inrange(0,1):
x = random.randint(1,33)print(x,end=" ")defCheck_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)defCheck_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 inrange(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)breakelif x =="2":
keyword =input("请输入想要查找的机构或号码")
Check_number(keyword)breakelif x =="3":
city =input("请输入想要查询的城市")
Check_city(city)else:print("输出错误,请重新输入")print("欢迎你重新使用")
import randomdef 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): c