与c对比
1.不需要以:结束
2.不指定类型,字符串使用 + 好连接,也可以是用格式字符串
3.缩进代替花括号,布尔表达式不需要括号
4.内置数据类型:bool,float,int,str
5.其他数据类型:range,list,tuple,dict,set
python是解释器
Python -> 字节码 -> 解释器
from XXX import Xxx
读取文件:csv
不需要main函数
导入函数使用名称空间分隔
int(),ValueError异常
/:除法,整数相除可以得到浮点,格式字符串获取小数点数字
//:除法截断
%:取余
==:比较字符串
字符串也是不可变的
----------------
函数不需要指定参数类型
使用函数前需要先定义
变量作用域是函数
命名参数和位置参数
乘法运算符运用到字符串上
聚合函数:sum(),len()
append()
列表切片
元素存在列表:in
from sys import argv, exit
人脸,语音,二维码
使用代码手动洗数据,filter,sort,distinct
聚合,排序,lambda,正则
提供存储功能,最终数据存储到文件;
使用数据结构和接口使操作数据更加高效;data type;index
使用SQL操作数据;
表关系,抽取共性成一张表,结构更加干净;
同时使用sql更加复杂,多表查询;
sql注入,并发(race condition)
盗窃发生在 2021 年 7 月 28 日,并且发生在汉弗莱街。
- 小偷是谁,
- 小偷逃到了哪个城市,以及
- 谁是小偷的同谋,谁帮助他们逃跑
SELECT people.name
FROM atm_transactions,bank_accounts,people
WHERE atm_transactions.account_number = bank_accounts.account_number
AND bank_accounts.person_id = people.id
AND atm_transactions.year = 2021
AND atm_transactions.month = 7
AND atm_transactions.day = 28
AND atm_transactions.transaction_type = "withdraw"
AND atm_transactions.atm_location = "Leggett Street"
INTERSECT
SELECT name
FROM people
WHERE phone_number
IN
(SELECT phone_calls.caller FROM "phone_calls"
WHERE year = 2021 AND month = 7 AND day = 28
AND duration < 60)
INTERSECT
SELECT name
FROM people
WHERE license_plate
IN
(SELECT license_plate FROM "bakery_security_logs"
WHERE year = 2021 AND month = 7
AND day = 28 AND hour = 10 AND minute > 15 AND minute < 25)
INTERSECT
SELECT people.name
FROM people
WHERE people.passport_number
IN
(SELECT passengers.passport_number
FROM passengers
WHERE passengers.flight_id
IN
(SELECT flights.id
FROM flights
WHERE flights.year = 2021 AND flights.month = 7 AND flights.day = 29
ORDER BY flights.hour,flights.minute
LIMIT 1))
Server,Client,Routers,Protocols,TCP/IP,DNS
CREATE TABLE purchase(
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
user_id INTEGER NOT NULL,
symbol TEXT NOT NULL,
current_price NUMBERIC NOT NULL,
amount INTEGER NOT NULL,
time TimeStamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY(user_id) REFERENCES users(id)
);