【Python】Python中一切皆对象

1.Python一切皆对象

def say(name='superzjx'):

print(name)

my_func = say

my_func('superzjx')

class Person:

def __init__(self):

print('init')

my_class = Person

my_class()

obj_list = []

obj_list.append(say)

obj_list.append(Person)

for item in obj_list:

print(item())

def print_type(item):

print(type(item))

obj_list = []

obj_list.append(say)

obj_list.append(Person)

for item in obj_list:

print_type(item)

def decorator_func():

print('decorator start')

return say

my_dec = decorator_func()

my_dec('Hello world')

2.type、class和object的关系

【Python】Python中一切皆对象

3.Python中常见的内置类型

以上是 【Python】Python中一切皆对象 的全部内容, 来源链接: utcz.com/a/73595.html

回到顶部