![图片[1]-怎么查看python变量值-uusu优素-乐高,模型,3d打印,编程](http://uusucn.zbbe.cn/wp-content/uploads/2024/01/5e73566b98911586.jpg)
有时候我们需要知道变量类型,但不知道如何查看
内置函数isinstance(object, (type1,type2…))
isinstance('content',str)
返回
TrueorFalse
使用内置函数type(object)
type()就是一个最实用又简单的查看数据类型的方法。type()是一个内建的函数,调用它就能够得到一个反回值,从而知道想要查询的对
像类型信息。
type使用方法
>>>type(1)
<type'int'>#返回整形
>>>type('content')
<type'str'>#返回字符串
type返回值属于type类型
>>>type(type(1)) <type'type'>#返回type类型原文来自:https://www.py.cn
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
















































暂无评论内容