python introduce
python introduce
解释器
CPython
python泛指Cpython, 使用C实现, 可以很方便的集成C代码. Cpython中有 Global Interpreter Lock(GIL),
同一时间只允许一个线程获取解释器的控制权. 一般使用多进程实现并发需求.
PyPy
JIT Python实现, 比CPython快很多
[Jython]
在JVM运行Python, 可以很容易与Java集成
[IronPython]
.net实现
[PythonNet]
.net...
后端Web应用开发框架
后端Web应用开发框架
Spring
ktor
Django
express
Reference
Why I would choose Ktor over any other Flask, hapi.js or Sinatra?
Django Vs Express: The Key Differences To Observe in 2022
Django REST framework vs Ktor
Spring Boot VS Django: What’s the difference in 2021?
python project structure
python project structure
python3 -m venv <path> # 创建虚拟环境
source <path>/bin/activate # 激活虚拟环境
deactivate # 退出虚拟环境
Reference
venv — Creation of virtual environments
Python Packaging User Guide
Installing Python Modules
Distributing Python Modules
Scope functions
Scope functions
可以在对象的上下文中执行代码块, 调用形成一个临时作用域, 在些范围内可以不带对象名称访问对象.
这个就叫scope functions
let, run, with, apply, also
上面都是在对象上执行代码块, 不同的是这个对象如果在块中可用.
Person("Alice", 20, "Amsterdam").let {
println(it)
it.moveTo("London")
it.incrementAge()
println(it)
}
val alice = Person("Alice", 20, "Amsterdam")
println(alice)
alice.moveT...
kotlin collections
kotlin collections
List, 一个有序集合, 通过下标访问元素, 元素可以重复
Set, 一个数学抽象集合, 无序, 唯一. 一般Map的key就是set. 默认LinkedHashSet, HashSet
Map(dictionary), key-value pairs. key是唯一的, 并且会关联一个value. value可以重复. 默认LinkedHashMap, HashMap
kotlin有 read-only 和 mutable
read-only 集合是convariant; mutable 不是convariant的
Constructing collections
Construct from elemen...
468 post articles, 59 pages.