Python语言基础
Python语言进阶
Python数据结构

删除对象

删除对象详细操作教程
以下实例为学习删除对象,具体代码如下:
# Filename : example.py
# Author by : www.lidihuo.com
class Person:
  def __init__(self, name, age):
    self.name = name
    self.age = age
  def myfunc(self):
    print("Hello my name is " + self.name)
p1 = Person("Bill", 63)
del p1
print(p1)
执行以上代码输出结果为:
# Filename : example.py
# Author by : www.lidihuo.com

Traceback (most recent call last):

  File "demo_class8.py", line 13, in <module>

    print(p1)

NameError: 'p1' is not defined
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4