在Python中定义变量时,不需要声明类型,但变量在内部是有类型的。例如,在交互式环境输入如下代码,即输出变量a的类型:
>>> a='test' >>> type(a) #调用函数type()得到变量a的类型 <class 'str'>