V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
110male
V2EX  ›  问与答

py 的函数,在定义时,不能指定参数的类型吗?

  •  
  •   110male · Dec 14, 2017 · 2291 views
    This topic created in 3056 days ago, the information mentioned may be changed or developed.
    maguowei
        1
    maguowei  
       Dec 14, 2017   ❤️ 1
    https://github.com/python/mypy 你要的是这个么?
    wwqgtxx
        2
    wwqgtxx  
       Dec 14, 2017 via iPhone   ❤️ 1
    py3 可以,但是只是形式上的,调用者依然可以不遵守
    Kilerd
        3
    Kilerd  
       Dec 14, 2017   ❤️ 1
    那你用 py 的意义在哪里?
    qs
        4
    qs  
       Dec 14, 2017   ❤️ 1
    上装饰器检查吧 运行的时候不符合就抛异常报错 然后函数注解里写明参数类型
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3188 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 00:27 · PVG 08:27 · LAX 17:27 · JFK 20:27
    ♥ Do have faith in what you're doing.