I have this code:
fields = ['name','email']
def clean_name():
pass
def clean_email():
pass
How can I call clean_name()
and clean_email()
dynamically?
For example:
for field in fields:
clean_{field}()
I used the curly brackets because it's how I used to do it in PHP but obviously doesn't work.
How to do this with Python?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…