美文网首页
02_类型检查

02_类型检查

作者: 秋的懵懂 | 来源:发表于2018-11-05 13:54 被阅读0次

    时间:2018-11-01 作者:魏文应


    一、类型检查

    类型检查,通过 type() 内建函数来实现变量类型检查:

    a = 123
    print(a)
    print(type(a))
    print(type(1))
    print(type(1.5))
    print(type(True))
    print(type('hello'))
    print(type(None))
    

    打印结果如下:

    123
    <class 'int'>
    <class 'int'>
    <class 'float'>
    <class 'bool'>
    <class 'str'>
    <class 'NoneType'>
    

    相关文章

      网友评论

          本文标题:02_类型检查

          本文链接:https://www.haomeiwen.com/subject/uabxxqtx.html