python 학습 18 일 째

원본 링크:http://www.cnblogs.com/EuanXu/p/9937462.html
import master

lst = ["akl", "obm"]
for i, item in enumerate(lst):
print(i,item)
while 1:
num = input(' ')
if num == '0':
master.akl()
if num == '1':
master.obm()
while 1:
s = input(' ')

#
if hasattr(master, s): #
fn = getattr(master, s) #
fn()
else:
print(' ')

print(getattr(master,"name"))
setattr(master, "name", 'Euan')
print(master.name)

class Car():
def __init__(self, color, pai, price):
self.color = color
self.pai = pai
self.price = price

def fly(self):
print(' ')

c = Car(" "," ",1000000000)
delattr(Car, "fly") #
c.fly()

setattr(Car,'fly', lambda self:print(' , '))
c.fly()

print(c.color)
setattr(c, 'color', ' ')
print(c.color)

print(getattr(c, 'pai'))
print(c.pai)

다음으로 전송:https://www.cnblogs.com/EuanXu/p/9937462.html

좋은 웹페이지 즐겨찾기