class Person:
def __init__(self):
self.__Name = 'hehe'
def shuchu(self):
print(self.__Name)
aa= Person()
print(aa.shuchu())
我想测试一下私有属性的作用。为什么print语句还会返回一个none。
class Person:
def __init__(self):
self.__Name = 'hehe'
def shuchu(self):
print(self.__Name)
aa= Person()
print(aa.shuchu())
我想测试一下私有属性的作用。为什么print语句还会返回一个none。
print(aa.shuchu())直接修改为
aa.shuchu()
因为你不是返回一个值,而是在shuchu里面自己print的