廖大python實戰教程第七天

2022-08-03 03:48:11 字數 1308 閱讀 7515

使用模板

mvc的全名是model view controller,是模型-檢視-控制器的縮寫,是一種軟體設計典範。使用mvc的目的是使m和v的**分離,從而使乙個程式可以有不同的表現形式。

這個地方在所難免。實在沒想到用ide照著敲都會有一些不注意的小細節錯誤。

一開始頁面是 404 not found。等查明原因後發現add_routes()函式沒有執行,裡面有三四處錯誤。一般來說,404 not found的日誌不會有這麼一句::add route get / => index(request),從此處我感受到了日誌的重要性。

意識到日誌的重要性,我就想著發上來,讓有疑惑的人對比一下。

info:root:create database connection pool...

info:root:init jinja2...

info:root:found model: user (table: users)

info:root:server started at

info:root:request: get /

info:root:response handler...

info:root:call with args:

info:root:sql: select `id`, `email`, `passwd`, `admin`, `name`, `image`, `created_at` from `users`

info:root:rows returned: 2

info:root:request: get /

info:root:response handler...

info:root:call with args:

info:root:sql: select `id`, `email`, `passwd`, `admin`, `name`, `image`, `created_at` from `users`

info:root:rows returned: 2

info:root:request: get /

info:root:response handler...

info:root:call with args:

info:root:sql: select `id`, `email`, `passwd`, `admin`, `name`, `image`, `created_at` from `users`

info:root:rows returned: 2

初學Python第七天

繼上次10.10注釋,到了序列這一章,開乙個新的章節 一 通用序列操作 定義 python中序列的通用操作,在列表 list 和元組 tuple 中都會用到。基礎的8類操作種類 索引 index 分片 slice 相加 add 乘法 multiply 成員 member 長度 length 最小值 ...

Python小白第七天

1.1變數 變數不需要先宣告 在使用變數前,需要對其先賦值 變數名可以包括字母 數字 下劃線,但不能以數字開頭 區分大小寫 1.2字串 雙引號或單引號內的東西 python i love you 或 python i love you 如果字串中需要出現單引號或雙引號,此時需要使用轉義符號 對出現的...

自學python第七天

函式式程式設計 函式式程式設計的乙個特點就是,允許把函式本身作為引數傳入另乙個函式,還允許返回乙個函式!函式式程式設計就是一種抽象程度很高的程式設計正規化,純粹的函式式程式語言編寫的函式沒有變數,因此,任意乙個函式,只要輸入是確定的,輸出就是確定的,這種純函式我們稱之為沒有 而允許使用變數的程式語言...