zoukankan      html  css  js  c++  java
  • [Python] Use Static Typing in Python 3.6

    In this lesson, you will learn how to statically type variables in Python 3.6 Static typing can help you avoid errors when consumers of your variables and functions call them with the incorrect data type. You will learn how to statically type strings, integers, booleans, Lists and Dicts. You will also learn how to automatically check for typing errors when coding and as part of your build workflow.

    from typing import Dict, List
    
    
    def add_num(a: int, b: int):
        return a + b
    
    
    my_string: str
    
    my_bool: bool
    
    
    my_nums: List[int]
    
    my_dict: Dict[str, int] = {
        "Patriots": 23,
        "Falcons": 7
    }
  • 相关阅读:
    C语言01
    C++面试总结更新
    Python网络爬虫与信息提取02
    Self-Driving Car 01
    Python网络爬虫与信息提取01
    Python-03
    Shell
    Python-05
    Python-04
    Python-02
  • 原文地址:https://www.cnblogs.com/Answer1215/p/9065407.html
Copyright © 2011-2022 走看看