Python----__init__初始化
来源:互联网 发布:超时空战士优化排期 编辑:程序博客网 时间:2024/05/05 12:45
init
初始化
class Cat: """这是一个猫类""" def __init__(self): print("初始化方法") def eat(self): print("Cats eat fish") def drink(self): print("Cats drink water")# 第一个对象调用前都会执行 __init__tom = Cat()tom.drink() # Cats drink waterprint(tom) # 内存地址:<__main__.Cat object at 0x0000000001EFA278>print("%d" % id(tom)) # 以10 进制 32481912print("%x" % id(tom)) # 以16 进制 1efa278lazy_cat = Cat()lazy_cat.eat() # Cats eat fishprint(lazy_cat) # 内存地址:<__main__.Cat object at 0x0000000001EFA320># 不推荐:类的外部添加属性, 如未找到会报错lazy_cat.name = 'lazy'
阅读全文
0 0
- Python----__init__初始化
- Python(3) python __init__()初始化及继承的实现
- Python : 定义一个应用程序的初始化方法 __init__()
- python __init__()
- python self __init__
- python __init__.py
- python __init__.py
- python __new__ __init__
- python __init__.py
- python __init__.py
- python之 __init__.py
- python __init__.py介绍
- 【python】__init__.py
- python __init__.py详解
- python __init__.py
- Python __new__ ,__init__,__call__
- python __init__.py
- Python模块 - __init__.py
- PAT考试乙级1021(C语言实现)
- springmvc项目(一)
- android 兼容性测试 CTS 测试过程(实践测试验证通过)
- python中MD5的使用
- mysql学习 stage1-2
- Python----__init__初始化
- 阻止networksetup询问密码
- Ctrlbox Project v2.3项目管理用户手册(四)——操作详解4.6
- 欢迎使用CSDN-markdown编辑器
- ubuntu中maven的安装与配置图文详解
- Kotlin基础
- 百度分享 ajax 或分页后显示不出问题解决方案
- 在控制台打印 MyBatis 生成的 sql 语句的配置方法
- Maven的Repo,应该选用Nexus还是Artifactory?