YCI生活小助理

2021-10-09 22:25:49 字數 3090 閱讀 2345

注意單詞拼寫

wether *weather

date *data

# 生活小助理

import random

phone_numbers_str =

"匪警[110],火警[119],急救中心[120],道路交通事故報警[122],水上求救專用**[12395],天氣預報[12121],報時服務[12117],森林火警[12119],電力服務[95598],紅十字會急救臺[999],公安簡訊報警[12110],通用緊急求救[112],信產部ip/**備案[010-66411166]"

weather_str =

"北京,2023年1月12日,多雲,8°c,-4°c,南風3級~上海,2023年1月12日,小雨,9°c,6°c,北風2級~廣州,2023年1月12日,陣雨轉多雲,22°c,15°c,持續無風向微風"

# r = random.randint(1,16)

#print(r)

#生成雙色球

defgenerate_unionlotto

(number)

:for j in

range(0

,int

(number)):

for i in

range(0

,6):

red = random.randint(1,

33)print

(red, end=

" ")

blue = random.randint(1,

16)print

(blue)

#號碼百事通

deffind_phone

(keyword)

: phone_list = phone_numbers_str.split(

",")

# print(phone_list)

for p in phone_list:

if p.find(n)!=-

1:print

(p)#得到

defget_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(

",")

# print(w)

weather =

# print(wether)

weather_data[weather[

"name"]]

= weather

#print(weather_date)

if city in weather_data:

#return weather_date[city]

return weather_data.get(city)

else

:return

defget_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(

",")

# print(w)

#weather =

weather =

dict

(name = w[0]

,date = w[1]

, weather = w[2]

,max

= w[3]

,min

= w[4]

, wind = w[5]

)# print(weather)

weather_data[weather[

"name"]]

= weather

# print(weather_data)

if city in weather_data:

return weather_data.get(city)

else

:return

while

true

:print

("1-雙色球隨機選號"

)print

("2-號碼百事通"

)print

("3-明日百事通"

)print

("0-結束程式"

) c =

input

("請輸入功能編號:"

)if c ==

"1":

n =input

("您要生成幾注雙色球號碼:"

) generate_unionlotto(n)

elif c ==

"2":

n =input

("請輸入您要查詢的機構或者**號碼:"

) find_phone(keyword = n)

elif c ==

"3":

n =input

("請輸入您要查詢的城市:"

) w = get_weather(n)

print

(w)if

"name"

in w:

# print(" /".format_map(w))

#print(" /".format_map(w))

print

(" / "

.format_map(w)

)else

:print

("未找到{}的天氣資料"

.format

(n))

print

("*************************="

)print

()

Python YCI生活小助理

import random deftcolorball number,n for i in range 0 number for j in range 0 1 x random.randint 1,33 print x,end defcheck number keyword contend 匪警 1...

生活小故事

有乙個人在森林中漫遊的時候,突然遇見了乙隻飢餓的老虎,老虎大吼一聲就撲了上來。他立刻用生平最大的力氣和最快的速度逃開,但是老虎緊追不捨,他一直跑一直跑一直跑,最後被老虎逼入了斷崖邊上。站在懸崖邊上,他想 與其被老虎捉到,活活被咬 肢解,還不如跳入懸崖,說不定還有一線生機。他縱身跳入懸崖,非常幸運的卡...

生活小故事

從前,有乙個脾氣很壞的男孩.他的爸爸給了他一袋釘子,告訴他,每次發脾氣或者跟人吵架的時候,就在院子的籬笆上釘一根。第一天,男孩釘了37根釘子。後面的幾天他學會了控制自己的脾氣,每天釘的釘子也逐漸減少了。他發現,控制自己的脾氣,實際上比釘釘子要容易的多。終於有一天,他一根釘子都沒有釘,他高興的把這件事...