class Person(object):
def __init__(self, name):
self.name = name
def say_something(self):
print('I am {}. Hello'.format(self.name))
self.run(3)
def run(self, num):
print('run '*num)
person = Person('Tom')
person.say_something()
Résultat d'exécution
I am Tom. Hello
run run run
Recommended Posts