資源簡介
定時拉取指定城市天氣并發送給指定好友,資源講解地址:https://www.cnblogs.com/swarmbees/p/10023491.html

代碼片段和文件信息
#?coding:?utf-8
import?os
class?City(object):
????def?__init__(self):
????????self.city?=?{}
????def?load(self?file):
????????if?os.path.exists(file):
????????????with?open(file?‘r‘?encoding?=?‘utf-8‘)?as?f:
????????????????cityInfo?=?f.readline().strip(‘\n‘)
????????????????while?cityInfo:
????????????????????datas?=?cityInfo.split(‘:‘)
????????????????????self.city[datas[0]]?=?datas[1]
????????????????????cityInfo?=?f.readline().strip(‘\n‘)
????def?find_code(self?city_name):
????????if?city_name?in?self.city:
????????????return?self.city[city_name]
????????return?‘‘
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????I.A....??????2026??2018-11-26?23:09??weath_report.py
????I.A....???????602??2018-11-26?20:45??city_code.py
????I.A....??????8268??2018-11-26?20:45??city_code.txt
????I.A....???????581??2018-11-26?22:52??mybot.py
????I.A....??????1680??2018-11-26?21:31??sender.py
????I.A....??????1466??2018-11-26?20:45??Timer.py
????I.A....??????1825??2018-11-26?20:45??weath_info.py
-----------?---------??----------?-----??----
????????????????16448????????????????????7
評論
共有 條評論