# -*- coding: utf-8 -*-
class Document():
def __init__(self, title, author, context):
print('init function called')
self.name='xxx'
harry_potter_book = Document('Harry Potter', 'J. K. Rowling', '... Forever Do not believe any thing is capable of thinking independently ...')
print(harry_potter_book.name)
C:\Python27\python.exe "C:/Users/TLCB/PycharmProjects/untitled2/python study/t15.py"
init function called
xxx
如果去掉__init__:
# -*- coding: utf-8 -*-
class Document():
# def __init__(self, title, author, context):
print('init function called')
self.name='xxx'
harry_potter_book = Document('Harry Potter', 'J. K. Rowling', '... Forever Do not believe any thing is capable of thinking independently ...')
print(harry_potter_book.name)
C:\Python27\python.exe "C:/Users/TLCB/PycharmProjects/untitled2/python study/t15.py"
init function c
__init__构造函数
最新推荐文章于 2023-07-27 22:57:20 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)