后端那些事 ---语言(Python)

静态语言,动态语言,弱类型语言,强类型语言

弱/强类型指的是语言类型系统的类型检查的严格程度。动/静指的是变量与类型的绑定方法

弱类型:
> "1"+2
'12'
强类型:
>>> "1"+2
Traceback (most recent call last):
  File "", line 1, in <module>
TypeError: cannot concatenate 'str' and 'int' objects
动态类型:
>>> a = 1
>>> type(a)
<type 'int'>
>>> a = "s"
>>> type(a)
<type 'str'>
静态类型:
Prelude> let a = "123" :: Int

<interactive>:2:9:
    Couldn't match expected type `Int' with actual type `[Char]'
    In the expression: "123" :: Int
    In an equation for `a': a = "123" :: Int
后端那些事 ---语言(Python)_第1张图片

你可能感兴趣的:(后端那些事 ---语言(Python))