沒對象?不要緊,new一個,趕忙來測試下本身new的技術如何吧。python
class Person(object): __country = 'China'
def __init__(self,name,age): print('建立對象中。。。') self.__name = name self.age = age print('你的對象信息:'.center(30,'*')) self.__query() print('恭喜脫單。。。'.center(30,'*'))
def query(self): print("country:%s"%self.__country) print("name:%s"%self.__name) print("age:%s"%self.age) self.__query()
def __query(self): print("country:%s" % self.__country) print("name:%s" % self.__name) print("age:%s" % self.age) Person('林小花',18)
請直接說出上面代碼結果及緣由:網絡
class Person(object): __country = 'China'
def __init__(self,name,age): print('建立對象中。。。') self.__name = name self.age = age print('你的對象信息:'.center(30,'*')) self.__query() print('恭喜脫單。。。'.center(30,'*'))
def query(self): print("country:%s"%self.__country) print("name:%s"%self.__name) print("age:%s"%self.age) self.__query()
def __query(self): print("country:%s" % self.__country) print("name:%s" % self.__name) print("age:%s" % self.age) gf = Person('林小花',18) print(gf.__country)
請直接說出上面代碼結果及緣由:app
class Person(object): __country = 'China'
def __init__(self,name,age): print('建立對象中。。。') self.__name = name self.age = age print('你的對象信息:'.center(30,'*')) self.__query() print('恭喜脫單。。。'.center(30,'*'))
def query(self): print("country:%s"%self.__country) print("name:%s"%self.__name) print("age:%s"%self.age) self.__query()
def __query(self): print("country:%s" % self.__country) print("name:%s" % self.__name) print("age:%s" % self.age) gf = Person('林小花',18) print(gf.age)
請直接說出上面代碼結果及緣由:測試
class Person(object): __country = 'China'
def __init__(self,name,age): print('建立對象中。。。') self.__name = name self.age = age print('你的對象信息:'.center(30,'*')) self.__query() print('恭喜脫單。。。'.center(30,'*'))
def query(self): print("country:%s"%self.__country) print("name:%s"%self.__name) print("age:%s"%self.age) self.__query()
def __query(self): print("country:%s" % self.__country) print("name:%s" % self.__name) print("age:%s" % self.age) gf = Person('林小花',18) print(gf.__name)
請直接說出上面代碼結果及緣由:spa
class Person(object): __country = 'China'
def __init__(self,name,age): print('建立對象中。。。') self.__name = name self.age = age print('你的對象信息:'.center(30,'*')) self.__query() print('恭喜脫單。。。'.center(30,'*'))
def query(self): print("country:%s"%self.__country) print("name:%s"%self.__name) print("age:%s"%self.age) self.__query()
def __query(self): print("country:%s" % self.__country) print("name:%s" % self.__name) print("age:%s" % self.age) gf = Person('林小花',18) gf.query()
請直接說出上面代碼結果及緣由:對象
class Person(object): __country = 'China'
def __init__(self,name,age): print('建立對象中。。。') self.__name = name self.age = age print('你的對象信息:'.center(30,'*')) self.__query() print('恭喜脫單。。。'.center(30,'*'))
def query(self): print("country:%s"%self.__country) print("name:%s"%self.__name) print("age:%s"%self.age) self.__query()
def __query(self): print("country:%s" % self.__country) print("name:%s" % self.__name) print("age:%s" % self.age) gf = Person('林小花',18) gf.__query()
請直接說出上面代碼結果及緣由: blog
class Person(object): __country = 'China' def __init__(self,name,age): print('建立對象中。。。') self.__name = name self.age = age print('你的對象信息:'.center(30,'*')) self.__query() print('恭喜脫單。。。'.center(30,'*')) def query(self): print("country:%s"%self.__country) print("name:%s"%self.__name) print("age:%s"%self.age) self.__query() def __query(self): print("country:%s" % self.__country) print("name:%s" % self.__name) print("age:%s" % self.age) gf = Person('林小花',18) gf.__country = 'America' print("你女友的國籍是:",gf.__country) gf.query() print(gf._Person__country) gf._Person__country = 'America2' print("你女友的國籍是:",gf.__country) gf.query() print(gf._Person__country)
請直接說出上面代碼結果及緣由:圖片
class Person(object): __country = 'China' def __init__(self,name,age): print('建立對象中。。。') self.__name = name self.age = age print('你的對象信息:'.center(30,'*')) self.__query() print('恭喜脫單。。。'.center(30,'*')) def query(self): print("country:%s"%self.__country) print("name:%s"%self.__name) print("age:%s"%self.age) self.__query() def __query(self): print("country:%s" % self.__country) print("name:%s" % self.__name) print("age:%s" % self.age) gf = Person('林小花',18) gf.__name = 'Lili' print("你女友的名字是:",gf.__name) gf.query() print(gf._Person__name) gf._Person__name = 'Lili2' print("你女友的名字是:",gf.__name) gf.query() print(gf._Person__name)
請直接說出上面代碼結果及緣由:it
提早祝君七夕happy。class
圖片來源於網絡,若有侵權,請聯繫刪除。