类型模块Python类型:types模块 类型模块
首先声明,我是一个菜鸟。一下文章中出现技术误导情况盖不负责Python内建函数type(object),用于返回以后object象对的类型。例如:
>>> type(1)
<type 'int'>
>>> type("1")
<type 'str'>
types模块义定了python中所有的类型,包含NoneType, TypeType, ObjectType....
types模块在所的位置为{%PYTHONPATH%\lib\types.py}.
实现法方很简单,把对应的类型赋值给变量:
NoneType = type(None)
TypeType = type
ObjectType = object
IntType = int
LongType = long
FloatType = float
BooleanType = bool
StringType = str
因此,在我们的码代中可以这样来用使:
>>> import types
>>> type(1)==types.IntType
True
>>> type("1")==types.StringType
True
文章结束给大家分享下程序员的一些笑话语录: 腾讯总舵主马化腾,有人曾经戏称如果在Z国选举总统,马化腾一定当选,因为只要QQ来一个弹窗”投马总,送Q币”即可。
页:
[1]