@(Python)[CH4]
Neil 完成 ch4 任務(wù)啦
任務(wù)成果地址 : City_weather+Database
-
任務(wù)成果截圖1:
成果圖鏈接 -
任務(wù)成功截圖2:
Update -
任務(wù)成功截圖3:
Update_01 -
任務(wù)成功截圖4:
error -
任務(wù)成功截圖5:
help -
任務(wù)成功截圖6:
database
程序使用說明地址: 暫無
個人教程地址: TBA
感想:
花了整整一周堅持練習(xí)Bootstrap, 總覺得這個如此美麗的東西將來肯定用得著,所以從開始迷茫,到一點(diǎn)點(diǎn)查資料跟著菜鳥教程一步步練習(xí)洼专,直到最后才有了現(xiàn)在如此“美麗”的頁面:)柳弄,當(dāng)然原环,距離真正的美麗還差很遠(yuǎn)滑臊,因為還有更精彩的風(fēng)景在后面坡慌,所以放一放手状原,擁抱一下數(shù)據(jù)庫斜脂。
說實(shí)話抓艳,數(shù)據(jù)庫的卡包內(nèi)容和鏈接都看了,很多不止一遍帚戳,但真正坐下來對著電腦還是會出現(xiàn)無從下手的囧境玷或。個人有深思過這個問題,ok片任,如果你真的天資及其聰穎偏友,或者你能極大程度的和時間鬧著玩,那你可以盡情的在時間長河中去個人探索自由馳騁对供,而大多數(shù)人位他,尤其是初次,用如此快節(jié)奏的方式學(xué)習(xí)一門新技能产场,可能你真的需要在時間和個人探索之間找到一個平衡鹅髓,而這個平衡點(diǎn)每個人其實(shí)都不一樣。要省時間京景,當(dāng)然最好的就是直接看同學(xué)的代碼窿冯,比如第一時間看Hugo的視頻,如果你需要要虐心感也叫自由探索自由馳騁确徙,然后親自爬過所有大坑醒串,這種收獲和體驗可想而知應(yīng)該就是永生難忘并及其具有價值执桌,但是,付出的時間也要遠(yuǎn)遠(yuǎn)大于前者厦凤,我個人完全不鼓勵直接看同學(xué)代碼鼻吮,也不鼓勵一開始就看視頻育苟,但同時较鼓,內(nèi)心覺得硬抗其實(shí)也是及其魯莽的舉措,尤其在你完全沒摸到門道违柏,甚至連問問題博烂,提issue都不知從何問起時和提起時。
所以在個人探索與翻閱同學(xué)代碼/觀看視頻之間要有個平衡漱竖,要能鍛煉到自己禽篱,但又不要讓自己陷入信心和時間上的無底線打擊,這個可能也是這4周以來在學(xué)習(xí)上的一些額外體會馍惹。
當(dāng)然躺率,最開心的是,看了同學(xué)的代碼万矾,懂了悼吱,然后碼出比ta更簡潔的代碼。最羨慕的是良狈,北上廣深的meetup!
總結(jié)
Bootstrap
- 網(wǎng)格系統(tǒng)后添,按照12等分對界面進(jìn)行劃分,非常方便進(jìn)行內(nèi)容和屬性編輯薪丁。
- 美麗三原素遇西,除了排版接下來就要屬字體了,推薦鏈接常用網(wǎng)頁字體严嗜。
- 其次是配色粱檀,此次界面是按照配色網(wǎng)的推薦進(jìn)行調(diào)整的。
CH4核心程序
- 在編輯核心程序時漫玄,思考了很多梧税,也嘗試了好多,最后采用try-except 主結(jié)構(gòu)實(shí)現(xiàn)了所有功能称近, 感覺比Hugo采用 if 主結(jié)構(gòu)更加簡潔第队,代碼如下,具體見成功任務(wù)
def process_request():
city = request.args.get('city')
try:
request.args.get('query') == "查詢"
weather_str = retrieve_data(city) #this weather_str also came from the database.py
return render_template("query.html", weather_str=weather_str)
except:
if request.args.get('history') == "歷史":
history_list = get_history()
return render_template("history.html", history_list=history_list)
elif request.args.get('help') == "幫助":
return render_template('help.html')
elif request.args.get('update') == "更新":
try:
location, weather = city.split(" ") #!!! say the web
update(location, weather)
return render_template('update.html')
except ValueError:
return render_template("error.html")
else:
try:
updated_time, location, weather, temperature = fetchWeather(city)
insert_data(updated_time, location, weather, temperature)
weather_str = '{}, {}的天氣為{}, 氣溫{}°'.format(updated_time, location, weather, temperature) # must be here, or there will be error
#history_list.append(weather_str) // this from the API
return render_template("query.html", weather_str=weather_str)
except KeyError:
return render_template("error.html",city=city)