其他资料
Python(十三)- 常用内置模块与第三方库_高中信息技术教材必修模块中出现的内置库与第三方库-CSDN博客
资料
https://docs.python.org/zh-cn/3/
https://docs.python-guide.org/
fluent python
effective python
进阶好文
https://zhuanlan.zhihu.com/p/336926012
python官方文档
https://docs.python.org/3/contents.html
python书籍
https://github.com/WeitaoZhu/Python
流畅的python笔记
https://www.zhihu.com/column/c_1526275373855289345
https://blog.csdn.net/senior218218/article/details/105144181
https://zhuanlan.zhihu.com/p/59698230
https://www.cnblogs.com/Eva-J/p/7277026.html
社区
开源项目
…
新特性
https://docs.python.org/zh-cn/3/whatsnew/index.html
3.8
- 海象运算符
if oid := data.get("oid"):
print(oid)
仅位置参数
# *号代表e,f必须用键值 # /号代表a,b必须用位置 def f(a, b, /, c, d, *, e, f): print(a, b, c, d, e, f)
f'{age=}'支持
author = "Generalzy"
print(f'{author=}')
# author='Generalzy'
3.9
字典合并运算符和字典更新运算符
d1, d2 = {1: 'a', 2: 'b'}, {2: 'a', 3: 'b'}
print(d1 | d2) # {1: 'a', 2: 'a', 3: 'b'} {**d1, **d2}
d1 |= d2
print(d1) # {1: 'a', 2: 'a', 3: 'b'} d1.update(d2)
3.10
https://docs.python.org/zh-cn/3/whatsnew/3.10.html
带圆括号的上下文管理器
作用:允许将过长的上下文管理器集能够以与之前 import 语句类似的方式格式化为多行的形式。
with (
CtxManager1() as example1,
CtxManager2() as example2,
CtxManager3() as example3,
):
...
match
3.11
执行效率提升,快10-60%,https://docs.python.org/zh-cn/3.11/whatsnew/3.11.html
Self type
作用:标注增加self类型
联合类型运算符
def square(number: int | float) -> int | float:
return number ** 2