推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
zywscq
V2EX  ›  Python

9 个 Python 中比较复杂的类型注解总结

  •  
  •   zywscq · Apr 24, 2024 · 3786 views
    This topic created in 749 days ago, the information mentioned may be changed or developed.
    1. TypeVar: 声明类型变量
    2. NewType:基于既有类型定义新类型
    3. Final Type:定义常量
    4. TypedDict:方便定义字典中键值对的类型
    5. Protocol:定义“鸭子类型”
    6. Union Type:一个变量,多种可能的类型
    7. Callable Types:定义函数等 Callable
    8. Annotated:除了类型之外,再加更多元数据
    9. TypeAlias:类型别名 原文链接: https://medium.com/techtofreedom/9-advanced-python-type-hints-that-will-improve-your-code-significantly-ae09ab3b3493?sk=829ad9b635a9422b8024b8ec383e0310
    8 replies    2024-04-25 18:26:08 +08:00
    nagisaushio
        1
    nagisaushio  
       Apr 24, 2024 via Android   ❤️ 4
    又来了,国外老哥
    LeeReamond
        2
    LeeReamond  
       Apr 24, 2024   ❤️ 1
    @nagisaushio 外国小哥一文帮你弄懂 Python 类型注释
    gesse
        3
    gesse  
       Apr 24, 2024
    免费好评
    sazima
        4
    sazima  
       Apr 24, 2024
    还有 Generic 泛型
    zywscq
        5
    zywscq  
    OP
       Apr 24, 2024
    @nagisaushio 哈哈哈,能说出这个梗的,都是老朋友了
    iorilu
        6
    iorilu  
       Apr 24, 2024
    类型注解越来越复杂了, 不亚于又学一遍 python 阿
    FlashEcho
        7
    FlashEcho  
       Apr 25, 2024
    这个帖子也没有总结啊,就是单纯把名字抛出来了,点进原文是自己写的付费文章,这种是否有推广的嫌疑?
    UN2758
        8
    UN2758  
       Apr 25, 2024
    @iorilu 看看远方的 rust 的类型注解吧,也非常挠头
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5647 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 52ms · UTC 07:53 · PVG 15:53 · LAX 00:53 · JFK 03:53
    ♥ Do have faith in what you're doing.