- @property将类中的属性变为私有的(类似于java中的private)
- @property使方法像属性一样调用,就像是一种特殊的属性
class C:
def __init__(self):
self._x = 5
@property
def x(self):
"""I'm the 'x' property."""
return self._x
c = C()
print(c.x)
复制代码
"""
list1 = ['Google', 'Runoob', 1997, 2000];
list2 = [1, 2, 3, 4, 5 ];
list3 = ["a", "b", "c", "d"];
#删除列表元素
del list2[0]
list2.remove(3)
list4 = list2+list3
print(list4)
list4.clear()
print(list4)
list4.append(2)
ret = list4.is_empty()
list
print(ret)
print(list4)
print(list1[1:3])#取前不取后
print(list2)
"""
tup1 = (50)
print(type(tup1))
tup1 = (50,)
print(type(tup1))
dict = {'Name': 'Runoob', 'Age': 7, 'Class': 'First'}
dict.update({'fengfeng':'吃饭'})
print(dict)
del dict['Name']
dict.clear()
del dict
复制代码