1 Star 0 Fork 0

趣味AI / python-small-examples

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
45.md 565 Bytes
一键复制 编辑 原始数据 按行查看 历史
vuefine 提交于 2020-08-23 12:40 . md-head
@author jackzhenguo
@desc 
@date 2019/3/10

45 查看对象类型

class type(name, bases, dict)

传入一个参数时,返回 object 的类型:

In [1]: class Student():
   ...:     def __init__(self,id,name):
   ...:         self.id = id
   ...:         self.name = name
   ...:     def __repr__(self):
   ...:         return 'id = '+self.id +', name = '+self.name
   ...: 

In [2]: xiaoming = Student(id='001',name='xiaoming')
In [3]: type(xiaoming)
Out[3]: __main__.Student

In [4]: type(tuple())
Out[4]: tuple
1
https://gitee.com/funny_ai/python-small-examples.git
git@gitee.com:funny_ai/python-small-examples.git
funny_ai
python-small-examples
python-small-examples
master

搜索帮助